|
TPCCLIB
|
Data and time processing functions. More...
#include "tpcclibConfig.h"#include <stdio.h>#include <stdlib.h>#include <time.h>#include <string.h>#include <locale.h>#include <ctype.h>#include <unistd.h>#include <math.h>#include "tpcextensions.h"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 calendar 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 | strDateValid (const char *str) |
| int | strDateValid2 (const char *str, char *intdate) |
| int | strDateValid3 (const char *str, char *intdate) |
| int | strDateValid4 (int dateint, char *intdate, int *year, int *month, int *day) |
| int | strTimeValid (const char *str) |
| int | strDateTimeValid (const char *str, char *intdate) |
| int | strDateTimeRead (const char *str, struct tm *date) |
| int | strDateRead (const char *str, struct tm *date) |
| 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) |
| double | strDateTimeDifference (const char *dt1, const char *dt0) |
| int | strDateTimeAdd (int s, char *dt) |
Data and time processing functions.
Definition in file datetime.c.
| char * ctime_r_int | ( | const time_t * | t, |
| char * | buf ) |
Convert calendar 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 119 of file datetime.c.
Referenced by parWriteRES().
| 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 31 of file datetime.c.
Referenced by ctime_r_int(), tacReadGEMS(), and timegm().
| 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 54 of file datetime.c.
Referenced by tacReadScanditronics().
| int strDateRead | ( | const 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. |
| date | Pointer to allocated struct tm where the date is written; undefined if date is not valid. |
Definition at line 378 of file datetime.c.
Referenced by tacReadGEMS(), and tacReadScanditronics().
| int strDateTimeAdd | ( | int | s, |
| char * | dt ) |
Add given time in seconds to the date and time.
| s | Time to add in seconds; can be negative. |
| dt | Pointer to date and time string, edited here. It must be allocated for at least 20 characters. |
Definition at line 537 of file datetime.c.
| double strDateTimeDifference | ( | const char * | dt1, |
| const char * | dt0 ) |
Calculate the difference in seconds between two dates and times in international date and time string format (YYYY-MM-DD hh:mm:ss).
| dt1 | Pointer to date and time string. |
| dt0 | Pointer to date and time string. |
Definition at line 519 of file datetime.c.
Referenced by dcmMListRead(), and imgReadDICOM().
| int strDateTimeRead | ( | const char * | str, |
| struct tm * | date ) |
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 |
| date | Pointer to allocated struct tm where date and time is written. undefined if date or time is not valid. |
Definition at line 350 of file datetime.c.
Referenced by abssWrite(), strDateTimeAdd(), strDateTimeDifference(), tacReadAllogg(), tacReadGEMS(), and tacReadScanditronics().
| int strDateTimeValid | ( | const char * | str, |
| char * | intdate ) |
Verify that specified string contains date and time in correct format (YYYY-MM-DD hh:mm:ss, DD.MM.YYYY hh:mm:ss, D.M.YYYY hh:mm:ss, DD.MM.YY hh:mm:ss, or D.M.YY hh:mm:ss). String must start with date, but any contents after time is ignored.
| str | String to be verified. |
| intdate | Pointer to preallocated string where date and time is written in international format (YYYY-MM-DD hh:mm:ss); enter NULL, if not needed. Undefined, if date is not valid. |
Definition at line 308 of file datetime.c.
Referenced by dcmDT2intl(), strDateTimeRead(), tacReadOldAllogg(), and tacReadSIF().
| int strDateValid | ( | const char * | str | ) |
Verify that 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 verified. |
Definition at line 155 of file datetime.c.
Referenced by dcmDA2intl(), strDateRead(), and strDateTimeValid().
| int strDateValid2 | ( | const char * | str, |
| char * | intdate ) |
Verify that specified string contains date in correct format (DD.MM.YYYY, D.M.YYYY, DD/MM/YYYY, or D/M/YYYY). String must start with date, but any contents after it is ignored.
| str | String to be verified. |
| intdate | Pointer to preallocated string where date is written in international format; enter NULL, if not needed. Undefined, if date is not valid. |
Definition at line 179 of file datetime.c.
Referenced by strDateRead(), and strDateTimeValid().
| int strDateValid3 | ( | const char * | str, |
| char * | intdate ) |
Verify that specified string contains date in correct format (DD.MM.YY, D.M.YY, DD/MM/YY, or D/M/YY). String must start with date, but any contents after it is ignored.
| str | String to be verified. |
| intdate | Pointer to allocated string where date is written in international format; enter NULL, if not needed. Undefined, if date is not valid. |
Definition at line 214 of file datetime.c.
Referenced by strDateRead(), and strDateTimeValid().
| int strDateValid4 | ( | int | dateint, |
| char * | intdate, | ||
| int * | year, | ||
| int * | month, | ||
| int * | day ) |
Verify that specified integer contains date in format YYYYMMDD.
| dateint | Integer 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. Undefined, if date is not valid. |
| 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 250 of file datetime.c.
| int strTimeValid | ( | const char * | str | ) |
Verify that 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 verified. |
Definition at line 284 of file datetime.c.
Referenced by dcmTM2intl(), iftPutFromString(), and strDateTimeValid().
| 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 443 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 thread-safe in Windows.
| tm | Pointer to struct tm. |
Definition at line 77 of file datetime.c.
Referenced by tmAdd().
| 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 structure. |
Definition at line 500 of file datetime.c.
Referenced by abssWrite(), and strDateTimeAdd().
| double tmDifference | ( | struct tm * | tm1, |
| struct tm * | tm0 ) |
Calculate the difference in seconds between two given dates and times.
| tm1 | Pointer to tm structure. |
| tm0 | Pointer to tm structure. |
Definition at line 486 of file datetime.c.
Referenced by strDateTimeDifference().