-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
resepct utc when passed to tz #2949
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -140,6 +140,14 @@ export default (o, c, d) => { | |
| // timestamp number || js Date || Day.js | ||
| return d(input).tz(timezone) | ||
| } | ||
|
|
||
| const hasExplicitOffset = /[Zz]|[+-]\d\d:?(\d\d)?$/.test(input) | ||
| if (hasExplicitOffset) { | ||
| const utcDate = d.utc(input, parseFormat) | ||
| utcDate.$x.$timezone = timezone | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doing it this way doesn't set the offset or any of the time fields so the resulting object likely doesn't do what you think it does here. It's also not covered by test cases, your input is UTC (not an offset), |
||
| return utcDate | ||
| } | ||
|
|
||
| const localTs = d.utc(input, parseFormat).valueOf() | ||
| const [targetTs, targetOffset] = fixOffset(localTs, previousOffset, timezone) | ||
| const ins = d(targetTs).utcOffset(targetOffset) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const hasTimezoneInfo = /Z|[+-]\d{2}:?\d{2}$/.test(input)
if (hasTimezoneInfo && !parseFormat) {
return d(input).tz(timezone)
}
Can we fix it in this way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah sounds good, will run a few tests