[m-dev.] time.localtime

Peter Wang novalazy at gmail.com
Wed Nov 27 16:59:27 AEDT 2013


On Fri, 22 Nov 2013 16:18:01 +1100, Julien Fischer <jfischer at opturion.com> wrote:
> On Fri, Nov 22, 2013 at 11:48 AM, Peter Wang <novalazy at gmail.com> wrote:
> 
> > Hi,
> >
> > The interpretation of time.localtime implicitly depends on timezone of
> > the environment that the process is running in.  Even if we don't
> > provide any way to modify the timezone from Mercury (yet), I think it
> > should take the I/O state.
> 
> 
> Agreed.
> 

Let me retract that.  time.time_t is an abstract type.  It can be viewed
(and realised, if necessary) that time_t values encapsulate the local
timezone, so that localtime/1 and ctime/1 are pure.

time_t values are produced by:

    :- pred time(time_t::out, io::di, io::uo) is det.

    :- func time.mktime(tm) = time_t.

    :- pred io.file_modification_time(string::in, io.res(time_t)::out,
             io::di, io::uo) is det.

The only problem is that mktime/1 gets the local time zone from nowhere.

Peter



More information about the developers mailing list