[Issue 19808] New: SysTime gives different results at compile vs. run time execution

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 15 15:59:29 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19808

          Issue ID: 19808
           Summary: SysTime gives different results at compile vs. run
                    time execution
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: david.eckardt at frequenz.io

void f()
{
  import std.datetime.systime: SysTime;
  import std.datetime.timezone: UTC;

  static immutable ctfe = SysTime.fromUnixTime(0, UTC());
  auto rtfe = SysTime.fromUnixTime(0, UTC());
  assert(ctfe == rtfe); // Succeeds
  string a = ctfe.toISOExtString(); // a == "1970-01-01T00:00:00+00:00"
  string b = rtfe.toISOExtString(); // b == "1970-01-01T00:00:00Z"
}

This behaviour is mentioned in
https://issues.dlang.org/show_bug.cgi?id=12507#c12

> … and thus will print out its timezone as +00:00 instead of z, which is
> perfectly legitimate per the spec.

Although both strings logically contain the same time information and comply
with the ISO standard, two SysTime instances comparing equal yet yielding
different strings depending on previous compile- vs. run-time execution is very
surprising.

--


More information about the Digitalmars-d-bugs mailing list