However, my suggestion would be to use gmtime instead of localtime and use the same algorithm. But that of course depends upon what the OP is really trying to do. I didn't see anything in the problem statement about local time. Epoch time is a monotonically increasing number of seconds from an arbitrary start time. Weird things can happen when translating UTC (GMT) based time back into a local time.
For a wild example: Samoa changes Date/Time Line. Smaller versions of this happens when we change between Summer and Winter time.
In reply to Re^2: epoch reduction
by Marshall
in thread epoch reduction
by neilwatson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |