i've read recently that time_t doesn't have to be in second resolution
but if it isn't, then what resolution could it be in?
time_t is not required to be represented as a number of <time unit>
since <epoch>. That said, if it IS represented as a number of <time
unit> since <epoch>, any time unit, regardless of how silly, and
any epoch is acceptable. It is a quality-of-implementation issue
that times near to now should be representable, and with fairly
decent resolution (an 8-bit integer counter of geologic ages would
be considered poor here, as would a 32-bit number of picoseconds
since the beginning of the universe. Putting the epoch at the END
of the universe is also problematical since I don't think anyone
knows when that is relative to now. The same applies to putting
it as the day of the assassination of World President Saddam Hussein).
One possible representation of time_t is:
hhHHSSMMmmddyyyy
substitute decimal digits for the values, then treat it as a decimal
integer. A time_t needs more than 48 bits for this representation.
yyyy = year (Y10K problem here!!)
mm = month (1-12)
dd = day of month (1-31)
HH = hour (0-24) [*]
MM = minute (0-60) [*]
SS = second (0-60) [*]
hh = hundredths of seconds (0-99)
[*] Some of these limits may seem a bit strange to allow for
leap seconds.
Note that the fields are put in a decidedly non-endian order, so
the result you get from adding or subtracting them is essentially
useless, and even comparing them as integers doesn't tell you which
comes first unless they happen to both be in the same second.
microseconds, milliseconds, are all valid?
Yes, as are nano-fortnights and a big integer type that packs the
28 characters of "Sat Apr 17 19:58:47 CDT 2004" into it.
also, does anyone know of an implementation
that does not use second resolution for a time_t?
Microsoft systems such as MS-DOS used a bitfield representation of
year, month, day, hour, minute, and seconds for file date
representations. I don't think they used it as a time_t, though.
BSD Unix systems also have a struct timeval which typically contains
a time_t and a counter for fractions of seconds. That also isn't
actually used as a time_t.
Gordon L. Burditt