timestamp_t as string or similar

Alberto Mardegan mardy at users.sourceforge.net
Tue Apr 16 23:50:51 PDT 2013


On 04/17/2013 01:33 AM, Linus Torvalds wrote:
> 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.

What is timestamp_t? Looking at the code, it seems to be the seconds 
since the epoch, that is the same as time_t; but I guess there must be 
some reason why you didn't use time_t?

If the reason is cosmetic, and indeed timestamp_t is the seconds since 
the epoch, we could just use
   QDateTime::fromTime_t(time).toString()
without doing the formatting in C.

Ciao,
   Alberto



More information about the subsurface mailing list