[LCP]Time conversions

Jack Lloyd lloyd at acm.jhu.edu
Thu Nov 28 06:02:01 UTC 2002


On Wed, 27 Nov 2002, Greg Black wrote:

> Jack Lloyd wrote:
>
> | I have an interesting time conversion problem. Basically, my application is
> | reading in a string specifying a time in UTC/GMT. I parse this down to some
> | integers (year, month, ..., second). At some later time, I would like to
> | convert this into a time_t (so it can be compared with another time_t
> | passed in by the application). The obvious way to do this would be to fill
> | in a struct tm with the values and call mktime. Unfortunatly mktime expects
> | a struct tm in localtime, and there is no alternative version for UTC as
> | there is for localtime.
>
> Many systems provide timegm() which does mktime() but treats the
> input data as UTC.

Aha! Thanks. There was no man page for timegm() on my machine, so I didn't
know about it's existence. -J




More information about the linuxCprogramming mailing list