|
VMS Help DCE, DCE_DTS, Application Routines, utc_mkanytime *Conan The Librarian |
NAME
utc_mkanytime - Converts a tm structure and TDF (expressing the time
in an arbitrary time zone) to a binary timestamp
SYNOPSIS
#include <dce/utc.h>
int utc_mkanytime( utc_t *utc,
struct tm *timetm,
long tns,
struct tm *inacctm,
long ins,
long tdf );
PARAMETERS
Input
timetm
A tm structure that expresses the local time; tm_wday and
tm_yday are ignored on input; the value of tm_isdt should
be -1.
tns Nanoseconds since the Time component.
inacctm
A tm structure that expresses days, hours, minutes, and
seconds of inaccuracy. If a null pointer is passed, or
if tm_yday is negative, the inaccuracy is considered to be
unspecified; tm_mday, tm_mon, tm_wday, and tm_isdst are
ignored on input.
ins Nanoseconds of the inaccuracy component.
tdf Time Differential Factor to use in conversion.
Output
utc Resulting binary timestamp.
DESCRIPTION
The utc_mkanytime() routine converts a tm structure and TDF (express-
ing the time in an arbitrary time zone) to a binary timestamp.
Required inputs include nanoseconds since Time and nanoseconds of
inaccuracy.
RETURN VALUES
0 Indicates that the routine executed successfully.
-1 Indicates an invalid time argument or invalid results.
EXAMPLES
The following example converts a string ISO format time in an
arbitrary time zone to a binary timestamp. This may be part of an
input timestamp routine, although a real implementation will include
range checking.
utc_t utc;
struct tm tmtime, tminacc;
float tsec, isec;
double tmp;
long tnsec, insec;
int i, offset, tzhour, tzmin, year, mon;
char *string;
/* Try to convert the string... */
if(sscanf(string, "%d-%d-%d-%d:%d:%e+%d:%dI%e",
&year, &mon, &tmtime.tm_mday, &tmtime.tm_hour,
&tmtime.tm_min, &tsec, &tzhour, &tzmin, &isec) != 9) {
/* Try again with a negative TDF... */
if (sscanf(string, "%d-%d-%d-%d:%d:%e-%d:%dI%e",
&year, &mon, &tmtime.tm_mday, &tmtime.tm_hour,
&tmtime.tm_min, &tsec, &tzhour, &tzmin, &isec) != 9) {
/* ERROR */
exit(1);
}
/* TDF is negative */
tzhour = -tzhour;
tzmin = -tzmin;
}
/* Fill in the fields... */
tmtime.tm_year = year - 1900;
tmtime.tm_mon = --mon;
tmtime.tm_sec = tsec;
tnsec = (modf(tsec, &tmp)*1.0E9);
offset = tzhour*3600 + tzmin*60;
tminacc.tm_sec = isec;
insec = (modf(isec, &tmp)*1.0E9);
/* Convert to a binary timestamp... */
utc_mkanytime(&utc, /* Out: Resultant binary timestamp */
&tmtime, /* In: tm struct that represents input */
tnsec, /* In: Nanoseconds from input */
&tminacc,/* In: tm struct that represents inacc */
insec, /* In: Nanoseconds from input */
offset); /* In: TDF from input */
RELATED INFORMATION
Functions: utc_anytime
utc_anyzone
|
|