Dumb questions about GMT offset in tm structure
Sun Mar 15 01:13:55 UTC 1987
Dumb question #1: what applications use the offset from GMT of
local time? (That is, why do we want the offset in the tm
structure in the first place?)
I've run across it in networking applications, such as mail, netnews,
and transactions. They get char string date/time info from some
other place (possibly around the world) and have to understand it.
Dumb question #2: if there's a way to turn tm structures into
time_t values, does the ability to do something like
offset = time_of_interest -
offset = -offset; depending on what sex you think the
offset should be) obviate the need for a GMT offset element in
the tm structure?
Partly. At the higher levels, what I really want to do is things like this:
Convert gmtime char string to localtime char string
Convert localtime char string to gmtime char string
Compare two times to see which is older.
Compare two times to see if one is more than X older or newer
than the other
Add or subtract X hours (minutes, days, seconds, years) from a time.
Also, a long isn't enough to handle the times of interest. Sometimes
we need subsecond precision. Sometimes we care about things that
happened in the 19th century (birthdates, for example.)
Part of me wonders if a floating type could be used for time_t.
Nobody wants subsecond precision on a birthdate, although they
might want it for times very close to "now". I guess what I
really want is a floating point where zero means "now", but
that doesn't exactly work out unless you throw in a fixed reference
More information about the tz