#include <time.h>
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:
-
str | Pointer 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. |
date | Pointer to allocated struct tm where the date is written |
References isdate(), isdate2(), and isdate3().
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:
-
str | Pointer 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. |
date | Pointer to allocated struct tm where date and time is written |
References isdatetime().
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:
-
str | String 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:
-
str | String to be checked; not changed in this routine |
intdate | Pointer 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:
-
str | String to be checked; not changed in this routine |
intdate | Pointer 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:
-
dateint | Integer to be checked; not changed in this routine |
year | Year is written in this pointer; enter NULL if not needed |
month | Month is written in this pointer; enter NULL if not needed |
day | Day 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:
-
str | String to be checked; not changed in this routine |
intdate | Pointer 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().
int isleapyear |
( |
long int |
year | ) |
|
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:
-
str | String 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().
long int math_div |
( |
long int |
a, |
|
|
long int |
b |
|
) |
| |
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:
-
totalsecs | number of seconds elapsed since 00:00:00 on January 1, 1970, UTC; can be negative to represent times before 1970 |
offset | offset seconds adding to totalsecs (e.g. -timezone) |
result | pointer to struct tm variable to receive broken-down time |
References __mon_yday, isleapyear(), leaps_between(), and math_div().