This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Need hints on parsing time strings
- From: tomas at tuxteam dot de
- To: tomas at tuxteam dot de
- Cc: libc-help at sourceware dot org, rm at seid-online dot de
- Date: Wed, 3 Nov 2010 20:46:13 +0100
- Subject: Re: Need hints on parsing time strings
- References: <20101102154426.GA6009@tomas>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Tue, Nov 02, 2010 at 04:44:26PM +0100, tomas@tuxteam.de wrote:
> Hi,
>
> I'm trying to parse date/time strings which look like:
>
> 2009-04-14T13:00:00 CEST
[...]
> You get the idea. My questions:
>
> (Q1) Is strptime the right approach?
> (Q2) Does strptime help me with the timezone thing?
[...]
> (Q3) How does that work in multithreaded environments?)
OK, replying to self. In the meantime, I discovered getdate and its
reentrant cousin getdate_r, which are quite a bit closer to what I need.
Among other things, they try to account for the timezone matched with %Z
(and not the TZ variable), which is nice and would take care of Q2 and
Q3; Still, what I get with most of the time strings is not a timezone
but an offset (e.g. +01:00 or CEST) which is preferable anyway, because
a timezone always may entail an ambiguity (when the clock readings
overlap, sometimes in spring, when summer time begins).
What's the status of gettime? What's the intention? The info page is a
bit vague, and for a good reason, since recognizing offsets/time zones
is necesarily guesswork.
Am I better off doing something myself?
Thanks
- -- tomÃs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFM0bwFBcgs9XrR2kYRAjQWAJ42cbNCla5FeILqHG1jR3GC+Aly2gCfR6Kl
8xGhwUKWJrBr+gKOB8iZGL0=
=nZK1
-----END PGP SIGNATURE-----