i've come across something odd, and was wondering
if anyone else had seen this before.

we have an internal (uint64) timestamp which is the number of
milliseconds since teh epoch UTC. Bill (a pseudonym) needed
to find out what hour a specific timestamp t corresponded to.

now i would have just said
        hour = t/(3600 * 1000);         // remember t is in milliseconds
        // if i wanted hr in 00..23 range: hour = hour%24;

bill said
        xx = t/1000
        strncpy(hr_str, &(ctime(&xx)[11]), 2);
        hr_str[2] = 0;
        hour = atoi(hr_str);

ignoring logic errors (we really wanted hour from teh epoch, and not
hour of teh day) and time errors (ctime does localtime, not UTC);
my question is, where does someone learn this technique?
i am gobsmacked.

------------------
Andrew Hume  (best -> Telework) +1 623-551-2845
and...@research.att.com  (Work) +1 none currently
AT&T Labs - Research; member of USENIX and LOPSA




_______________________________________________
Tech mailing list
Tech@lopsa.org
http://lopsa.org/cgi-bin/mailman/listinfo/tech
This list provided by the League of Professional System Administrators
 http://lopsa.org/

Reply via email to