From: Dario Teixeira <darioteixeira@yahoo.com>
To: caml-list@inria.fr, Eric Cooper <ecc@cmu.edu>
Subject: Re: [Caml-list] Localising timestamps
Date: Wed, 9 Feb 2011 10:22:35 -0800 (PST) [thread overview]
Message-ID: <909070.84855.qm@web111510.mail.gq1.yahoo.com> (raw)
In-Reply-To: <20110209174648.GC14218@localhost>
Hi,
> This might not meet your performance requirements, but it's
> certainly
> easy to program with Unix.process_open etc.
>
> $ TZ=Europe/Paris date --date="2010-07-01 15:30 UTC" +"%F
> %T %Z"
> 2010-07-01 17:30:00 CEST
>
> The built-in date parser is quite powerful.
Currently I'm using glibc's routines accessed via a small C stub, since
Ocaml's Unix library does not give direct access to the 'tzname' array [1].
I'm avoiding the concurrency issues related to setting the TZ environment
variable only because the web application is written using Ocsigen and
thus also Lwt, allowing me control when there is a switch to another thread.
Nevertheless, this mechanism of changing a global TZ variable to affect
the behaviour of a function is ugly and error-prone. Hence why I'm
looking for a purely functional solution.
Ironically, glibc already includes all the code to make the zoneinfo
parsing, and it's a pity that it does not expose it to userspace in a
more flexible manner (and yes, I realise there is probably some POSIX
mandate that justifies this broken interface). I'm beginning to
understand why the Debian folks switched to eglibc...
Anyway, apparently what is happening at the moment is that any applications
with similar requirements to mine just duplicate and adapt the relevant code
from glibc. Postgresql is doing this, for example.
Cheers,
Dario
[1] http://caml.inria.fr/mantis/view.php?id=5063
prev parent reply other threads:[~2011-02-09 18:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-09 15:34 Dario Teixeira
2011-02-09 17:46 ` Eric Cooper
2011-02-09 18:22 ` Dario Teixeira [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=909070.84855.qm@web111510.mail.gq1.yahoo.com \
--to=darioteixeira@yahoo.com \
--cc=caml-list@inria.fr \
--cc=ecc@cmu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox