timestamp_t as string or similar

Linus Torvalds torvalds at linux-foundation.org
Tue Apr 16 14:33:08 PDT 2013


On Tue, Apr 16, 2013 at 2:18 PM, Amit Chaudhuri
<amit.k.chaudhuri at gmail.com> wrote:
>
> Ultimately, I'm looking to convert to QString so char * would do.  I've not
> seen any references to asctime in the code, but my current guess is I need
> to use time.c to create a tm and then use asctime.  Seems a bit around the
> houses - am I missing something?

Don't use asctime. We've had trouble with it, it doesn't do a good job
of localization etc.

Currently we just do "utc_mkdate()" on it, and print things out in
whatever needed format. So far we haven't had *that* many cases, and
the format for them has been sufficiently varied that there hasn't
been much reason for a helper function (I don't think *any* of them
actually want the asctime/ctime format). But if you want to make some
helper functions for creating the most common formats, go wild. Just
make sure you do *not* use asctime, and instead just do the trivial
lookup by hand (ie use the "weekday()" and "monthname()" helpers to
create the textual parts.

Just grep for utc_mkdate() and you'll see examples.

             Linus


More information about the subsurface mailing list