std.algorithm can not be used inside pure functions?
Jonathan M Davis via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat May 6 08:08:17 PDT 2017
On Saturday, May 6, 2017 2:14:41 PM CEST Szabo Bogdan via Digitalmars-d-
learn wrote:
> On Saturday, 6 May 2017 at 13:21:10 UTC, Adam D. Ruppe wrote:
> > On Saturday, 6 May 2017 at 13:19:17 UTC, Szabo Bogdan wrote:
> >> a.begin.toISOExtString,
> >
> > I believe that function is not marked pure if it is a SysTime
> > because it needs to pull global timezone info.
> >
> > What is the type of a.begin?
>
> oh yes, I get it... begin and end are `SysTime`.. there is any
> workaround for this?
Not really, no.
The SysTime operations should be pure so long as they don't involve the
TimeZone (e.g. adding and substracting is fine), but converting to a string
involves using the TimeZone, because it needs to convert the value from UTC
to whatever the time zone is. It would be nice if TimeZone operations could
be pure, but they fundamentally can't be because that doesn't work when
dealing with the system's local time.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list