Yes I mean roughly the same
The TicksToDateTime method should show that itās off in toffee by what looks like the utc offset. It should be roughly the time it takes for my to run the second console app.
Yes I mean roughly the same
The TicksToDateTime method should show that itās off in toffee by what looks like the utc offset. It should be roughly the time it takes for my to run the second console app.
I really hate test cases that make me play āWhere is Waldoā to even find what the bug is supposed to be.
Yes but I dont know a better way of doing this. I want to compare toffee and island output, can I do that in a single test ?
No, but you could use consistent input rather than UtcNow ;). But let me see.
This is freaky
var ticksFromNow := DateTime.UtcNow.Ticks;
Log($'{ticksFromNow}');
var ticksFromEpoche := new DateTime(1970,1,1).Ticks;
Log($'{ticksFromEpoche}');
~> Process IslandConsoleApplication started testing, took 0.884.
2022-07-07 10:30:17.130149-0400 IslandConsoleApplication[24300:8376179] 637928010170001296
2022-07-07 10:30:17.130491-0400 IslandConsoleApplication[24300:8376179] 621355968000000000
~> Process IslandConsoleApplication terminated with exit code 0. Ran for 1.512
~> Process ToffeeConsoleApplication started testing, took 0.171.
2022-07-07 10:30:23.501082-0400 ToffeeConsoleApplication[24309:8376284] 637927866234998532
2022-07-07 10:30:23.502129-0400 ToffeeConsoleApplication[24309:8376284] 621355968000000000
~> Process ToffeeConsoleApplication terminated with exit code 0. Ran for 4.408
The exact same code, called on Now differs vastly between Island And Toffee, but called on 1970 gives the same result. How can this be, is NSDate (used on Toffee) does not have time zone knowledge?
Ah, now i understand what the problem is!
consider this, looking at the actual date values, not the ticks:
var now := DateTime.UtcNow;
Log($"now {now.ToString("yyyy-mm-dd HH:mm:ss")}");
var ticksFromNow := now.Ticks;
Log($'{ticksFromNow}');
var newNnow := new DateTime(ticksFromNow);
Log($"new {newNnow.ToString("yyyy-mm-dd HH:mm:ss")}");
var epoch := new DateTime(1970,1,1);
Log($"epoch {epoch}");
var ticksFromEpoch := epoch.Ticks;
Log($'{ticksFromEpoch}');
~> Process IslandConsoleApplication started testing, took 1.114.
2022-07-07 10:47:15.994415-0400 IslandConsoleApplication[25564:8393190] now 2022-47-07 14:47:15
2022-07-07 10:47:15.994447-0400 IslandConsoleApplication[25564:8393190] 637928020350009849
2022-07-07 10:47:15.994473-0400 IslandConsoleApplication[25564:8393190] new 2022-47-07 14:47:15
2022-07-07 10:47:15.994507-0400 IslandConsoleApplication[25564:8393190] epoch 01/01/1970 00:00:00
2022-07-07 10:47:15.994515-0400 IslandConsoleApplication[25564:8393190] 621355968000000000
2022-07-07 10:47:15.994760-0400 IslandConsoleApplication[25564:8393190] d 2022-07-07 14:47:15 +0000
~> Process IslandConsoleApplication terminated with exit code 0. Ran for 1.599
~> Process ToffeeConsoleApplication started testing, took 0.165.
2022-07-07 10:47:21.769983-0400 ToffeeConsoleApplication[25569:8393308] now 2022-47-07 14:47:21
2022-07-07 10:47:21.770039-0400 ToffeeConsoleApplication[25569:8393308] 637927876417668100
2022-07-07 10:47:21.770259-0400 ToffeeConsoleApplication[25569:8393308] new 2022-47-07 10:47:21
2022-07-07 10:47:21.773695-0400 ToffeeConsoleApplication[25569:8393308] epoch 1970-01-01 04:00:00 +0000
2022-07-07 10:47:21.773727-0400 ToffeeConsoleApplication[25569:8393308] 621355968000000000
2022-07-07 10:47:21.773774-0400 ToffeeConsoleApplication[25569:8393308] d 2022-07-07 14:47:21 +0000
~> Process ToffeeConsoleApplication terminated with exit code 0. Ran for 4.227
Weāre off on the wring foot with new DateTime(1970,1,1)
because that creates midnight LOCAL TIME, not UTC, so thats off by 4 hours (and our fixes yesterday compensated (wrongly) for this. We need to revert those (again), and instead fix the constructor.
Do you mean like my pull request where I changed the timezone of the calendar ?
Yeah.
looks good now, I think:
~> Process IslandConsoleApplication started testing, took 0.967.
now 2022-06-07 15:06:54
637928032140005938
new 2022-06-07 15:06:54
date 01/01/1970 00:00:00
621355968000000000
new 1970-00-01 00:00:00}}
epoch 05/06/1975 08:32:05
623067859250000000
new 1975-32-05 08:32:05}}
~> Process IslandConsoleApplication terminated with exit code 0. Ran for 1.482
~> Process ToffeeConsoleApplication started testing, took 0.364.
now 2022-07-07 15:07:00
637928032201851580
new 2022-07-07 15:07:00
date 1970-01-01 00:00:00 +0000
621355968000000000
new 1970-00-01 00:00:00}
epoch 1975-06-05 08:32:05 +0000
623067859250000000
new 1975-32-05 08:32:05}
~> Process ToffeeConsoleApplication terminated with exit code 0. Ran for 4.256
~> Process EchoesTestApplication started testing, took 1.305.
now 2022-07-07 15:07:02
637928032224940550
new 2022-07-07 15:07:02
date 01/01/1970 12:00:00
621355968000000000
new 1970-00-01 00:00:00}
epoch 05/06/1975 08:32:05
623067859250000000
new 1975-32-05 08:32:05}
~> Process EchoesTestApplication terminated with exit code 0. Ran for 0.841
This and some m ore fixes for Java and .NET are in as well. More effort is now being done to ensure RTL2 DateTimeās are UTC always.
var now := System.DateTime.Now;
var date: DateTime := now;
writeLn($"now {now.ToString("yyyy-MM-dd HH:mm:ss")}");
writeLn($"now.Kind {now.Kind}");
writeLn($"date {date.ToString("yyyy-MM-dd HH:mm:ss")}");
writeLn($"date.IsUTC {date.IsUTC}");
now prints
now 2022-07-07 11:49:17
now.Kind Local
date 2022-07-07 15:49:17
date.IsUTC True
on .NET
Thanks I think this is working ok now in Toffee.