Mark Horton seismo!cbpavo.MIS.OH.ATT.COM!mark
Sun Feb 1 22:17:55 UTC 1987

I was VERY VERY happy to see mktime, as it turned out to be just what
I needed for an application I'm supporting.  (Actually, I had to alter
it somewhat - the major change was that mktime speaks local time, and
I needed a function that spoke UTC.  Easy when I had the source, but
it's worth mentioning that the UTC flavor is also useful.)

What did I need it for?  Well, I'm supporting a set of routines that
provide X.410 style transactions over a network.  These transactions
have time stamps in them, and the time stamps are in ASCII, in a format
that conforms (almost) to the appropriate ISO standards.  These routines
are mostly a cut up ctime.c, but I also had to supply functions to
take strings received over the network (which are always in UTC) and
do things like convert them to local time (for logs and for machines
that keep time in local time), add N hours, etc.

I'm enclosing the manual pages for my routines (the code itself is,
I'm sorry to say, considered proprietary to AT&T, but the interface
is open.)  I consider this just an expedient solution, and not necessarily
the end-all wonderful solution.

Note that it does not provide a routine like mktime to the users, since
I want to hide the time_t time from the users.  (We have to worry about
birth dates of parents of people alive today, so the 32 bit time_t isn't
adequate.  I don't really support that yet, but I don't provide user
access to time_t so they won't write code now they'll be sorry for later.)


isonow \- create ISO format string describing current date/time
isodcmp \- compare two ISO format dates
iso2local \- convert ISO date to local time
iso2gmt \- convert ISO date to UTC time
isoadd \- add a fixed offset to an ISO date
.B "char *"
.B "isonow();"
.B "int"
.B "isodcmp(d1, d2);"
.B "char *d1, *d2;"
.B "char *"
.B "iso2local(date)"
.B "char *date;"
.B "char *"
.B "iso2gmt(date)"
.B "char *date;"
.B "char *"
.B "isoadd(date, days, hours, minutes, seconds)"
.B "char *date;"
.B "int days, hours, minutes, seconds"
These routines manipulate ISO format date/time strings,
as defined in the MDTP specification.
Other routines may be added, as needed, later.
.I isonow
returns a character string, in ISO format, describing the
current date and time.
Only one of the ISO choices is used, namely:
for example
The first date is in the USA Eastern time zone, the second
in the Australian Central time zone,
and since isonow always returns GMT, the third sample is more typical.
The trailing E means
.I exact ,
as opposed to
B for
.I before
or P for
.I post
.I isodcmp
compares two ISO format times, telling which is earlier.
It returns \-1 if the first is earlier, 0 if they are the same,
and +1 if the second is earlier.
.I iso2local
takes an ISO format date (in either Z time zone, local time, or
any other time zone) and converts it to the local time zone.
It returns a string in ISO format indicating the local time zone.
.I iso2gmt
takes an ISO format date (in any time zone)
and converts it to the Z (GMT) time zone.
It returns a string in ISO format indicating the Z time zone.
.I isoadd
takes an ISO format date (in any time zone)
and adds the given number of days, hours, minutes, and seconds
to it.
The numbers may be positive or negative.
It returns a string in ISO format indicating the Z time zone.
In the interests of speed,
.I isodcmp
does not work correctly if any other variant of ISO format is
used (e.g. seconds are missing, or a Z time zone is used, or
a precision is included), or if the two time zones are not the same.

More information about the tz mailing list