03-08-06 12:52 PM
shyam wrote:
> time_t epoch;
>
> epoch = time(NULL);
>
> if(epoch == (time_t)-1)
> {
> //handle error
> }
>
> is this ok and enough?
Hi Shyam
Well, all other values are (at least in principle) legal
returnvalues. Only the special case (time_t)-1 is reserved to
indicate an error.
However, if you have some additional knowledge about the
time your program is used you could do some additional checking.
For example, if you know, that your program will not be used
before the year 2006, then any returnvalue, that computes
to a year between the_epoch and 2005 could be regarded as
invalid ... at least such a value would indicate that
the computer clock goes wrong.
Same thing ... if you dont expect this version of the program
to run (unmodified) after 2008 ... well, regard everything
bigger that 2008 as an error as well.
Rainer
[ Post a follow-up to this message ]
|