Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local date is deserialized as UTC timezone in Safari on macOS #380

Open
1 of 2 tasks
nattster opened this issue Feb 4, 2020 · 7 comments
Open
1 of 2 tasks

Local date is deserialized as UTC timezone in Safari on macOS #380

nattster opened this issue Feb 4, 2020 · 7 comments

Comments

@nattster
Copy link

nattster commented Feb 4, 2020

Package Version: 1.7.0

  • nodejs
    • nodejs version: ______
    • os name/version: _____
  • 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:

  1. Deserialize the local date (without timezone data) with AutoRest ( --model-date-time-as-string=false, the default value)
    2019-01-10T10:00:00
  2. 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

  1. User timezone is GMT+7 and browser is Google Chrome 79 on Windows 10
    Deserialized as local time correctly.
    image

  2. User timezone is GMT+7 and browser is Safari 12.1.2 on mac OS
    image (44)

Additional context
Suspect the problem coming from here:
https://github.com/Azure/ms-rest-js/blob/master/lib/serializer.ts#L205

@xirzec
Copy link
Member

xirzec commented Sep 22, 2020

What service is returning this date without timezone data? It feels like the service should always specify the timezone or Z for UTC.

@ArjunSureshKumar92
Copy link

Facing a similar issue. Is there a solution for this yet?
Thanks.

@jeremymeng
Copy link
Member

It's unfortunate that new Date(dateString) behavior is different and inconsistent across browsers.

@xirzec
Copy link
Member

xirzec commented Mar 26, 2021

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?

@teepobharu
Copy link

teepobharu commented Jun 16, 2022

Tried on both browser and found out the conversion seems to work fine now both Chrome and safari.

Chrome

image

Safari: Version 15.5 (17613.2.7.1.8)

image

@xirzec
Copy link
Member

xirzec commented Jun 16, 2022

@mpodwysocki can you confirm that Safari fixed this for you as well?

@mpodwysocki
Copy link
Member

@xirzec confirmed on Safari:

  • Version 15.5 (17613.2.7.1.8)
  • Release 146 (Safari 15.4, WebKit 17614.1.14.10.6)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants