TPCCLIB
|
Date and time functions. More...
Go to the source code of this file.
Functions | |
struct tm * | gmtime_r (const time_t *t, struct tm *tm) |
Convert time_t to GMT struct tm. | |
struct tm * | localtime_r (const time_t *t, struct tm *tm) |
Convert time_t to local time in struct tm. | |
time_t | timegm (struct tm *tm) |
Inverse of gmtime, converting struct tm to time_t. | |
char * | ctime_r_int (const time_t *t, char *buf) |
Convert calendard time t into a null-terminated string of the form YYYY-MM-DD hh:mm:ss, with length of 19 characters and the null. | |
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 verbose) |
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) |
double | tmDifference (struct tm *tm1, struct tm *tm0) |
void | tmAdd (int s, struct tm *d) |
Date and time functions.
Definition in file datetime.c.
char * ctime_r_int | ( | const time_t * | t, |
char * | buf ) |
Convert calendard time t into a null-terminated string of the form YYYY-MM-DD hh:mm:ss, with length of 19 characters and the null.
This is a replacement of the thread-safe ctime_r function which converts to date and time in english format.
t | Pointer to calendar time ; do not give pointer to int here, like &e7mhdr.scan_start_time |
buf | Pointer to string where the date and time will be written. It must be pre-allocated for at least 20 characters. |
Definition at line 110 of file datetime.c.
Referenced by atnMake(), ecat7MHeaderToIFT(), ecat7PrintMainheader(), fitWrite(), imgGetEcat63MHeader(), imgInfo(), imgSetEcat63MHeader(), imgWriteEcat63Frame(), imgWriteFrame(), plotdata(), resWrite(), resWriteHTML_table(), and sifPrint().
int get_date | ( | char * | str, |
struct tm * | date ) |
Reads date from a standard string representation of date.
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 |
Definition at line 377 of file datetime.c.
Referenced by resRead().
int get_datetime | ( | char * | str, |
struct tm * | date, | ||
int | verbose ) |
Reads time and date from a standard string representation of date and time.
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 |
verbose | Verbose level; if <=0, then nothing is printed into stdout |
Definition at line 322 of file datetime.c.
Referenced by ecat7EditMHeader(), fitRead(), resRead(), and selectEcat931Calibrationfile().
struct tm * gmtime_r | ( | const time_t * | t, |
struct tm * | tm ) |
Convert time_t to GMT struct tm.
This version of gmtime_r function is here for systems (at least Windows) where it is not defined. Uses gmtime, which is threadsafe in Windows.
t | Pointer to time_t; do not give pointer to int here, like &e7mhdr.scan_start_time |
tm | Pointer to struct tm, to be filled here |
Definition at line 22 of file datetime.c.
Referenced by ctime_r_int(), ecat63AddImg(), ecat63WriteAllImg(), ecat7EditMHeader(), ecat7ReadMainheader(), ecatCopy7to63mainheader(), imgSetAnalyzeHeader(), imgSetEcat63MHeader(), imgWriteAnalyze(), res2ift(), sifWrite(), time_to_tm(), and timegm().
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.
str | String to be checked; not changed in this routine |
Definition at line 146 of file datetime.c.
Referenced by dcmDA2intl(), 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.
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. |
Definition at line 168 of file datetime.c.
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.
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. |
Definition at line 199 of file datetime.c.
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.
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 |
Definition at line 230 of file datetime.c.
Referenced by ecat7ReadMainheader().
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.
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. |
Definition at line 280 of file datetime.c.
Referenced by dcmDT2intl(), and get_datetime().
int isleapyear | ( | long int | year | ) |
Check for leap year.
year | Year |
Definition at line 423 of file datetime.c.
Referenced by time_to_tm().
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.
str | String to be checked; not changed in this routine |
Definition at line 259 of file datetime.c.
Referenced by dcmTM2intl(), iftRead(), and isdatetime().
long int leaps_between | ( | long int | year1, |
long int | year2 ) |
Calculates the number of leap years between year1 and year2.
year1 | Year 1 |
year2 | Year 2 |
Definition at line 435 of file datetime.c.
Referenced by time_to_tm().
struct tm * localtime_r | ( | const time_t * | t, |
struct tm * | tm ) |
Convert time_t to local time in struct tm.
This version of localtime_r function is here for systems (at least Windows) where it is not defined. Uses localtime, which is threadsafe in Windows.
t | Pointer to time_t; do not give pointer to int here, like &e7mhdr.scan_start_time |
tm | Pointer to struct tm, to be filled here |
Definition at line 46 of file datetime.c.
long int math_div | ( | long int | a, |
long int | b ) |
Division for long integers.
a | A/b |
b | a/B |
Definition at line 409 of file datetime.c.
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.
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 |
Definition at line 452 of file datetime.c.
time_t timegm | ( | struct tm * | tm | ) |
Inverse of gmtime, converting struct tm to time_t.
Otherwise same as mktime, except that mktime uses local time. Uses gmtime_r or gmtime_s, if available, otherwise gmtime, which is threadsafe in Windows.
tm | Pointer to struct tm |
Definition at line 69 of file datetime.c.
Referenced by ecat63Scanstarttime(), ecat63ScanstarttimeToTm(), ecat7EditMHeader(), fitRead(), get_datetime(), imgGetMicropetHeader(), resRead(), sifRead(), tmAdd(), and upetScanStart().
void tmAdd | ( | int | s, |
struct tm * | d ) |
Add given time in seconds to the date and time.
s | Time to add in seconds; can be negative |
d | Pointer to tm struct |
Definition at line 514 of file datetime.c.
double tmDifference | ( | struct tm * | tm1, |
struct tm * | tm0 ) |
Calculate the difference in seconds between two given dates and times.
tm1 | Pointer to tm struct |
tm0 | Pointer to tm struct |
Definition at line 502 of file datetime.c.
Referenced by selectEcat931Calibrationfile().