Skip to content

Removed manual conversion to local time in date conversions - #55

Merged
oliverbock merged 2 commits into
JavascriptNet:masterfrom
Ablu:datetime
Sep 21, 2018
Merged

oliverbock merged 2 commits into
JavascriptNet:masterfrom
Ablu:datetime

Conversation

@Ablu

@Ablu Ablu commented Sep 3, 2018

Copy link
Copy Markdown
Collaborator

Calling ToLocalTime() leads to changes of the hour component. Since in JavaScript Date is basically simply a number starting from 1970-01-01 UTC we should not do any conversions here. This also means that the test which simply checked that new Date(2010, 9, 10) equals new DateTime(2010, 10, 10) was wrong. C# does not do any conversions by default, so new DateTime(2010, 10, 10) does not specificy any timezone. The JavaScript code should match the UTC Date of 2010-10-10 (00:00:00) converted to the local timezone, for example, 2010-10-09 (22:00:00) for MESZ (GMT+2).

@Ablu Ablu changed the title Datetime Removed manual conversion to local time in date conversions Sep 3, 2018
@Ablu

Ablu commented Sep 3, 2018

Copy link
Copy Markdown
Collaborator Author

Interesting... The Appveyor build fails when comparing new Date() with the current DateTime from C#... Locally it works. I will try to see what goes wrong there...

DateTime overloads the - operator.
@Ablu

Ablu commented Sep 21, 2018

Copy link
Copy Markdown
Collaborator Author

@spahnke would be cool if you could check whether the tests make sense. Date stuff is always ugly... :/.

@oliverbock should work now :)

@Ablu

Ablu commented Sep 21, 2018

Copy link
Copy Markdown
Collaborator Author

somehow github did not handle my forced push to my branch...

JavaScript usually does not care a lot about timezones, but since the
conversion happens via milliseconds since epoch (which is UTC based) one
needs to be a bit careful about which conversions to do where.

Added/moved tests to a central place so there is an overview over all
date related tests.
@Ablu

Ablu commented Sep 21, 2018

Copy link
Copy Markdown
Collaborator Author

Ok. A second forced push fixed it

@spahnke

spahnke commented Sep 21, 2018

Copy link
Copy Markdown
Collaborator

I will review this on Monday.

@Ablu

Ablu commented Sep 21, 2018

Copy link
Copy Markdown
Collaborator Author

CI failure is an unrelated test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants