[Ur] Proposing 'readTime'

Gian Perrone gdpe at itu.dk
Sun May 15 08:43:54 EDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

I've come upon a need to deal with some time functionality, and the
current pair of functions timef/readUtc appear insufficient --
principally, because there exists no easy way to detect the current
timezone so as to manually perform the timezone adjustment to UTC.
Consequently, the following does not work:

[...]
    currentTm <- now;
    fmt <- return (timef "%x %T" currentTm);
    error (case readUtc fmt of None => <xml/> | Some t => <xml>{[fmt]} -
{[t]}</xml>)

We should expect this to print the current time twice, however, if your
local time happens to not be in UTC, then you're going to get a timezone
adjustment, and two completely different times displayed!

I propose a 'readTime' function to exist in addition to 'readUtc' that
will simply read a formatted time string as though it were in local
time.  I've attached a patch to implement just this when applied against
the latest Ur/Web from Mercurial.  In my example above, replacing
'readUtc' with 'readTime' provides the expected behaviour, such that
readTime is properly an inverse of timef.

Thanks,
Gian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNz8p7AAoJEDd5xfOXfbYMC4AIAMfc5jVTHlEOQjNRL3AuCRkY
8Z3XeEZUBIL9XgBSyp0FY+DAiRl7R8q+CypCWPaK7tViFVI27ObrvPEUw1U+h+S1
j1MXVmk7e9TslqF5jznXfUA7dAq7OFVZGzATuvUe8xs1/e+FJkwKm8VGwg5GGIZA
v0SpAaECzKpTnz2ZZNwywxWrllY/G+mTX2fvXz6/L4DcvMD+sbVqS72FdAacf44i
beoMrvNM3gsj7TP6Y9dtI5o7c7S21heh4SsYBzHSefRWSP9tn3mw3bbUSK4zmdT+
uKUAh+VEra5h35OZXnrI6t5q64Z7xjM9eL7zR4blc79B9zb637dkMByfpxiShzY=
=abPi
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: readTime.patch
URL: <http://www.impredicative.com/pipermail/ur/attachments/20110515/832d097d/attachment.asc>


More information about the Ur mailing list