[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Monotone-devel] Notes on time and date handling
From: |
William Uther |
Subject: |
Re: [Monotone-devel] Notes on time and date handling |
Date: |
Tue, 20 Mar 2007 18:40:37 +1100 |
On 04/03/2007, at 6:21 PM, Zack Weinberg wrote:
As I mentioned this morning, I have replaced all our uses of
boost::date_time with bespoke logic; in the process I got to take a
good hard look at what we do with dates and why.
[snip]
The other thing I think we should consider changing is date *output*.
We currently take those ISO 8601 strings straight from the date certs
and splat them into log output (or whatever). It might make sense to
convert them to local time and/or to the user's locale's date format.
This would not be hard to implement.
I wanted to look into this. Was there a process you had in mind to
convert the times?
You could do something like (and this is unchecked, untested, "typed
directly into a mail program" code):
#include <ctime>
char *UTC_time_str_from_cert;
struct tm utc_tm;
time_t time;
char buf[30];
strptime(UTC_time_str_from_cert, "%FT%T", & utc_tm);
time = timegm(&utc_tm);
ctime_r(&time, buf);
But I don't know how reasonable that is from an i18l viewpoint (I've
not done a huge amount of date handling before, and none in C++).
Any suggested improvements?
Cheers,
Will :-}