Functions
datetime.h File Reference
#include <time.h>
Include dependency graph for datetime.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int isdate (char *str)
int isdate2 (char *str, char *intdate)
int isdate3 (char *str, char *intdate)
int isdate4 (int dateint, int *year, int *month, int *day)
int istime (char *str)
int isdatetime (char *str, char *intdate)
int get_datetime (char *str, struct tm *date)
int get_date (char *str, struct tm *date)
long int math_div (long int a, long int b)
int isleapyear (long int year)
long int leaps_between (long int year1, long int year2)
void time_to_tm (time_t totalsecs, int offset, struct tm *result)

Function Documentation

int get_date ( char *  str,
struct tm *  date 
)
Reads date from a standard string representation of date.
Returns:
Returns 0 when successful, <>0 in case of an error.
Parameters:
strPointer to string that contains date in one of the formats YYYY-MM-DD, DD/MM/YYYY, DD.MM.YYYY, DD/MM/YY, or DD.MM.YYYY. This string is not modified.
datePointer to allocated struct tm where the date is written

References isdate(), isdate2(), and isdate3().

Here is the call graph for this function:

int get_datetime ( char *  str,
struct tm *  date 
)
Reads time and date from a standard string representation of date and time.
Returns:
Returns 0 when successful, <>0 in case of an error.
Parameters:
strPointer to string that contains date and time in one of the formats YYYY-MM-DD hh:mm:ss, DD.MM.YYYY hh:mm:ss, or DD/MM/YY hh:mm:ss This string is not modified.
datePointer to allocated struct tm where date and time is written

References isdatetime().

Here is the call graph for this function:

int isdate ( char *  str)
Check if specified string contains date in correct international format
(YYYY-MM-DD). String must start with date, but any contents after
it is ignored.
Returns:
Returns 0 if date is in correct format, -1 if format is correct but date is invalid, and otherwise <>0.
Parameters:
strString to be checked; not changed in this routine

Referenced by get_date(), and isdatetime().

int isdate2 ( char *  str,
char *  intdate 
)
Check if specified string contains date in correct format
(DD.MM.YYYY or DD/MM/YYYY). String must start with date, but any contents
after it is ignored.
Returns:
Returns 0 if date is in correct format, -1 if format is correct but date is invalid, and otherwise <>0.
Parameters:
strString to be checked; not changed in this routine
intdatePointer to allocated string where date is written in international format; enter NULL, if not needed.

Referenced by get_date(), and isdatetime().

int isdate3 ( char *  str,
char *  intdate 
)
Check if specified string contains date in correct format
(DD.MM.YY or DD/MM/YY). String must start with date, but any contents
after it is ignored.
Returns:
Returns 0 if date is in correct format, -1 if format is correct but date is invalid, and otherwise <>0.
Parameters:
strString to be checked; not changed in this routine
intdatePointer to allocated string where date is written in international format; enter NULL, if not needed.

Referenced by get_date(), and isdatetime().

int isdate4 ( int  dateint,
int *  year,
int *  month,
int *  day 
)
Check if specified integer contains date in format YYYYMMDD.
Returns:
Returns 0 if date is in correct format, -1 if format is correct but date is invalid, and otherwise <>0.
Parameters:
dateintInteger to be checked; not changed in this routine
yearYear is written in this pointer; enter NULL if not needed
monthMonth is written in this pointer; enter NULL if not needed
dayDay is written in this pointer; enter NULL if not needed
int isdatetime ( char *  str,
char *  intdate 
)
Check if specified string contains date and time in correct format
(YYYY-MM-DD hh:mm:ss, DD.MM.YYYY hh:mm:ss, or DD.MM.YY hh:mm:ss).
String must start with date, but any contents after time is ignored.
Returns:
Returns 0 if date and time are in correct format, <0 if format is correct but date or time is invalid, and otherwise <>0.
Parameters:
strString to be checked; not changed in this routine
intdatePointer to allocated string where date and time is written in international format (YYYY-MM-DD hh:mm:ss); enter NULL, if not needed.

References isdate(), isdate2(), isdate3(), and istime().

Referenced by get_datetime().

Here is the call graph for this function:

int isleapyear ( long int  year)
int istime ( char *  str)
Check if specified string contains time in correct format
(hh:mm:ss). String must start with time, but any contents after
it is ignored.
Returns:
Returns 0 if time is in correct format, -1 if format is correct but time is invalid, and otherwise <>0.
Parameters:
strString to be checked; not changed in this routine

Referenced by iftRead(), and isdatetime().

long int leaps_between ( long int  year1,
long int  year2 
)

Calculates the number of leap years between year1 and year2.

References math_div().

Referenced by time_to_tm().

Here is the call graph for this function:

long int math_div ( long int  a,
long int  b 
)

Referenced by leaps_between(), and time_to_tm().

void time_to_tm ( time_t  totalsecs,
int  offset,
struct tm *  result 
)

Convert calendar time to local broken-down time. This function is copied from GNU C Library with tiny modifications.

Parameters:
totalsecsnumber of seconds elapsed since 00:00:00 on January 1, 1970, UTC; can be negative to represent times before 1970
offsetoffset seconds adding to totalsecs (e.g. -timezone)
resultpointer to struct tm variable to receive broken-down time

References __mon_yday, isleapyear(), leaps_between(), and math_div().

Here is the call graph for this function: