Steve Summit via tz said:
But now there's an alternative: take the same struct tm, and hand it to strftime with a format of %s. (That's a strange, alternative way of doing it, that I at least would never think of, but once strftime %s exists, I can't say that it's wrong.)
Speaking of strange, alternative ways of processing time ... On the few days either side of the 1999-2000 transition, I was site lead for one of the control centres of a major telephone and Internet service provider. More precisely, I was lead 08:00 to 20:00 daily and reserve lead between 20:00 and 08:00, meaning I could go back to the hotel so long as I answered any phone calls. But on The Night I decided to stay there to see what happened and just in case more hands were needed. At about 00:05 we got the only report of a Y2k bug to hit the entire company: a widget that customers could put on their web site to show the date and time was displaying "01 01 19100" instead of "01 01 2000". I volunteered to fix this and dug into the web site code to find the widget and see what was going on. My guess had been that someone had written sprintf with format "19%d" and argument tm_year instead of format "%d" and argument tm_year+1900. No. I have mercifully forgotten the exact code, but it was along the lines of: sprintf (buffer, "19%s%s", int_to_str (tm_year / 10), int_to_str (tm_year % 10)); -- Clive D.W. Feather | If you lie to the compiler, Email: clive@davros.org | it will get its revenge. Web: http://www.davros.org | - Henry Spencer Mobile: +44 7973 377646