Datelib
Mydates - Functions for Informix, UNIX, and Mydate
date formats.
This document describes the functions provided and the Datatypes
Manipulated by the Mydates.c and getdates.y modules. These include
functions to convert between Informix DATE, Informix DATETIME, various
UNIX date and time formats, and some new date and time formats that
these
modules provide.
Data Types:
Idate_t is a 'C' typedef of Informix's DATE data type which stores the
number of days since December 31, 1899 (ie a value of 1 == 1/1/1900):
This library describes four date formats which are useful for various
sorting and processing dates and times, these are:
Mydate4_t Date, stored in a long integer, as CCYYMMDD
(ie as CC*1000000 + YY*10000 + MM * 100 + DD)
Mydate6_t Date stored as a structure containing 3 shorts MM,
DD, & CCYY.
My_Datetime Data structure, similar to timeval, which qstores date
and time accurate to the nearest microsecond (1/10^6). The
structure contains a Mydate4_t and two longs containing the
number of seconds since midnight and number of microseconds
since the last second. The structure is kept normalized.
gdt_t This is a struct tm plus a nanoseconds field and a
timezone. Normally UTC/GMT is stored with the timesome set to
local minutes west of UTC. Defined in getdateandtime.h.
Functions:
String conversion functions:
getdateandtime The underlying string to date function all the others
use. Returns a success/error code and fills a gdt_t
structure.
strtodate4 Convert character string to a Mydate4_t date. Accepts a
pointer to a char array and returns a Mydate4_t;
strtodate6 Convert character string to a Mydate6_t date. Accepts a
pointer to a char array and a pointer to a Mydate6_t to
hold the result.
strtoidate Convert string in format to Informix DATE type. Accepts a
char array and returns a Idate_t.
strtomydt Convert string to My_Datetime structure. Accepts a pointer
to a character string and a pointer to a My_Datetime_t to
hold the result. Uses an enhanced version of the EMACS
getdate function, can convert anything sensible (like
"3 hours ago yesterday" or "1998-05-19 3:15:52.582347").
Convert between various date/time formats
Between various mydates library formats
gdttomydt Convert gdt_t date/time to My_Datetime_t.
Mydate4to6 Convert Mydate4_t date to a Mydate6_t date. Accepts a
pointer to a Mydate6_t to hold the result and a Mydate4_t.
Mydate6to4 Convert Mydate6_t date to Mydate4_t date. Accepts a
Mydate6_t and returns a Mydate4_t.
Between various mydates formats and Informix date/time formats
Mydate6toidate Convert Mydate6_t date to Informix DATE type. Accepts a
Mydate6_t and returns an Idate_t.
Mydate4toidate Convert Mydate4_t date to Informix DATE type. Accepts a
Mydate4_t and returns an Idate_t.
idatetoMydate6 Convert Informix DATE type to Mydate6_t date. Accepts a
pointer to a Mydate6_t to hold the result and an Idate_t.
idatetoMydate4 Convert Informix DATE type toMydate4_t date. Accepts an
Idate_t and returns an Mydate4_t.
idttomydt Convert Informix DATETIME type to My_Datetime structure.
Accepts a dtime_t and a pointer to a My_Datetime_t to hold
the result.
ivltomydt Convert Informix INTERVAL type to My_Datetime structure.
Accepts an intrvl_t and a pointer to a My_Datetime_t to
hold the result. My_Datetime_t is treated as holding an
interval as a normalized number of centuries, years,
months, days, seconds, microseconds. Not tested for
non-default precision of the starting range value.
mydttoidt Convert My_Datetime date to Informix DATETIME type.
Accepts a My_Datetime_t, a pointer to a dtime_t to hold the
result, and an integer containing the encoded precision for
the result.
Convert between various Informix and UNIX date/time formats.
idatetotime Convert Informix DATE to UNIX time_t based at midnight.
Accepts and Idate_t and returns a time_t.
timetoidate Convert Informix UNIX time_t to Informix DATE. Accepts a
time_t and returns an Idate_t.
Convert between mydates formats and UNIX date/time formats.
(Note that My_Datetime_t can hold dates after Jan 18, 2038 22:14:07 (UNIX
max time)
timetomydt Convert UNIX time_t to My_Datetime_t. Accepts a time_t and
a pointer to a My_Datetime_t to hold the result.
timevaltomydt Convert UNIX timeval structure to My_Datetime structure.
Accepts a struct timeval and a pointer to a My_Datetime_t
to hold the result.
mydttotime Convert My_Datetime structure to UNIX time_t. Accepts a
My_Datetime_t and a pointer to a time_t to hold the result.
mydttotimeval Convert My_Datetime structure to UNIX timeval structure.
Accepts a My_Datetime_t and a opinter to a struct timeval
to hold the result.
Convert various formats to UNIX standard date/time string.
mydttostr Convert My_Datetime structure to a String assuming local time.
mydttostrlcl Convert My_Datetime structure to String assuming My_Datetime
contains UTC, timezone can be specified.
*gdt_format Format a gdt_t in UNIX standard string format as either UTC or
local time.
Utility functions
gdt_Validate_Tm Validate a tm structure for internal consistency. (Structures
produced by some UNIX library functions are not internally
consistent neccessarily, this checks as mydates assumes the
gdt_t structure is internally consistent.