Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ utc_mkanytime(3dts) — DCE 3.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

utc_mkanytime(3dts)  —  Subroutines

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

timetmA tm structure that expresses the local time; tm_wday and tm_yday are ignored on input; the value of tm_isdt should be -1. 

tnsNanoseconds since the time component. 

inacctmA 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. 

insNanoseconds of the inaccuracy component. 

tdfTime differential factor to use in conversion. 

Output

utcResulting binary timestamp. 

Description

The utc_mkanytime() routine converts a tm structure and TDF (expressing the time in an arbitrary time zone) to a binary timestamp.  Required inputs include nanoseconds since time and nanoseconds of inaccuracy. 

Return Values

 0Indicates that the routine executed successfully. 

-1Indicates 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(3dts), utc_anyzone(3dts). 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026