Well, I usually try to teach folks how to fish, but some just need to be spoon fed…..here's how you quote the standard:
Code:
From: ISO/IEC 9899:1999 (E)
7.23 Date and time <time.h>
7.23.1 Components of time
...
3 The types declared are size_t (described in 7.17);
clock_t and time_t which are arithmetic types capable of representing
times; and struct tm which holds the components of a calendar time,
called the broken-down time.
...
7.23.2.4 The time function
Synopsis
1 #include <time.h>
time_t time(time_t *timer);
Description
2 The time function determines the current calendar time. The encoding of
the value is unspecified.
Returns
3 The time function returns the implementation’s best approximation to
the current calendar time. The value (time_t)(-1) is returned if the
calendar time is not available. If timer is not a null pointer, the
return value is also assigned to the object it points to.
This is from C99 but applies equally to C89.
There's a big difference between arithmetic properties (my original post) and an arithmetic type. The standard defines time_t as arithmetic type so that a comparison to (time_t)(-1) can be made. More importantly, the encoding of the time value is not defined. Meaning it could be seconds, micro-seconds, nano-seconds, or none of the above. The encoding doesn't even have to be in any unit of time, it could be a binary encoded decimal (BCD) of date/time values (adding 20 to a BCD doesn't make any sense).
Under ISO C, time_t is an abstract type for which the only valid arithmetic operation is comparison to (time_t)(-1).
As a side note, under the Single Unix Specification (the current POSIX standard), the time_t value returned by the time() function is defined to be in units of seconds. This is the most common implementation I've seen over the years.
So, (once again) if you're not concerned with portability of source code under ISO C, simply follow the documentation that came with your standard C library implementation. As a contributor to these forums, I'm simply following the convention of pointing out what is standard and what isn't standard (as far as I understand it).
I prefer "boo-yaa" over "busted"
gg