News for hackers. Stuff that matters.
Re:What every programmer should know about time by andrewcooke on Sunday July 03, 2011 @11:27PM (#2725273)
just to add to the examples here: last week i was writing code to handle calibration data from seismic detectors. these are connected to GPS receivers and so have pretty accurate times. yet when i triggered a calibration it would start 1 minute in the past. somehow the receiver was moving back in time before starting the calibration....

...or ntpd on the test computer had failed and the machine was a minute fast :o) so the code to search for data now looks backwards in time as well as forwards.

incidentally, does anyone know of a really good API for time (including calendars etc)? python's (which is largely a thin layer over C) is a horrible mess, for example.

Re:What every programmer should know about time by masklinn on Monday July 04, 2011 @02:01AM (#2725556)
> incidentally, does anyone know of a really good API for time (including calendars etc)? python's (which is largely a thin layer over C) is a horrible mess, for example.

The only date & time API I've ever seen praised is Joda (JDK/Java library). Joda's author went on to redesign it from scratch (though with inspiration from his work on Joda) for JSR-310, Java's new Date and Time API.

Re:What every programmer should know about time by njl on Sunday July 03, 2011 @11:57PM (#2725323)
I haven't played with it much, but the dateutil[1] package seems to do some nice stuff.

[1] http://labix.org/python-dateutil

Re:What every programmer should know about time by rvkennedy on Monday July 04, 2011 @07:48AM (#2726250)
Watch out for GPS time: it ignores leap seconds, and is currently, exactly fifteen seconds ahead of UTC.
Re:What every programmer should know about time by andrewcooke on Monday July 04, 2011 @09:31AM (#2726485)
thanks. currently everything is as insensitive to time as possible (during calibration the data are tagged, so i look for the block of tagged data near the correct time).
Re:What every programmer should know about time by roel_v on Monday July 04, 2011 @04:20AM (#2725818)
boost::date_time. I've cursed at it in the beginning, but it does things the Right Way, and I've been saved a number of times by its fighting back against shortcuts (like using Unix time - the issues identified in the article are real and a good summary, but the solution only works for the case where you need to work within a limited time span, from 1970 until a few decades into this century.)
Re:What every programmer should know about time by exDM69 on Monday July 04, 2011 @01:59PM (#2727257)
C++0x standard library is pretty nice too. std::chrono and std::thread work nicely together.

Right now I'm working with C, pthreads and struct timespec's and it makes me wish for a good time handling library.