On Jul 18, 12:28 am, Erik Wikström <Erik-wikst...@telia.comwrote:
On 2007-07-17 20:58, Mark wrote:
I want to simply get the unix style epoch time
(number of secs to now from Jan 01, 1970 UTC) for
use as a timestamp to track the staleness of some
objects. So I don't care about time zones or whatever
as long as it's consistent. So I picked the epoch time
UTC getting the value I wanted, "timestamp", this way:
What's wrong with just including time.h/ctime and using time()? While
it's not guaranteed to be the number of seconds since the epoch (could
be millisecond or something else) in the C and C++ standards it will be
on both Windows and POSIXS systems, and even if it's not, it will still
work as a timestamp (if you only want it to indicate staleness).
time_t isn't guaranteed to be an integral type---it could be
double. (In practice, of course, you're code probably isn't
portable everywhere, and I don't know of a system where time_t
isn't integral. It's what I'd do as well.)
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34