ms-rest-js
ms-rest-js copied to clipboard
Local date is deserialized as UTC timezone in Safari on macOS
Package Version: 1.7.0
- [ ] nodejs
- nodejs version: ______
- os name/version: _____
- [x] browser
- name/version: Safari 12.1.2 Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior:
- Deserialize the local date (without timezone data) with AutoRest ( --model-date-time-as-string=false, the default value)
2019-01-10T10:00:00 - Date is assumed UTC, and deserialized incorrectly
2019-01-10T17:00:00 GMT+0700
Expected behavior
2019-01-10T10:00:00 GMT+0700
Datetime without timezone, should be treated as user's local time, not UTC.
Screenshots
-
User timezone is GMT+7 and browser is Google Chrome 79 on Windows 10 Deserialized as local time correctly.

-
User timezone is GMT+7 and browser is Safari 12.1.2 on mac OS

Additional context Suspect the problem coming from here: https://github.com/Azure/ms-rest-js/blob/master/lib/serializer.ts#L205
What service is returning this date without timezone data? It feels like the service should always specify the timezone or Z for UTC.
Facing a similar issue. Is there a solution for this yet? Thanks.
It's unfortunate that new Date(dateString) behavior is different and inconsistent across browsers.
Since Temporal is still a ways off, what do we think about using something like https://www.npmjs.com/package/dayjs to handle parsing and converting to Date?
Tried on both browser and found out the conversion seems to work fine now both Chrome and safari.
Chrome

Safari: Version 15.5 (17613.2.7.1.8)

@mpodwysocki can you confirm that Safari fixed this for you as well?
@xirzec confirmed on Safari:
- Version 15.5 (17613.2.7.1.8)
- Release 146 (Safari 15.4, WebKit 17614.1.14.10.6)