Comments (15)
Hi, can I be assigned to this issue?
from moment.
Hi, can I be assigned to work on this issue?
from moment.
Hi,
Having the same issue with 'Europe/Copenhagen' timezone. It looks like moment.js is still using the Standard Time (+01:00) instead of DST (+02:00)
from moment.
Hi @kalina559, are you still having this issue in local development or just production?
from moment.
@kenyaplenty in both
from moment.
@kalina559 are you doing any specific checks between DST and standard time?
from moment.
@kenyaplenty nope, just calling tz() on a utc date
from moment.
This is something I'm also seeing for a number of different timezones. It seems that moment is not currently supporting DST at all for 2023 and beyond.
Example:
> let timeZone = 'America/Los_Angeles';
let winterDateStr = '2022-12-04T17:05';
let summerDateStr = '2022-06-04T17:05';
console.log('2022 Winter ISO Time ' + moment.tz(winterDateStr, timeZone).toISOString());
console.log('2022 Winter is DST ' + moment.tz(winterDateStr, timeZone).isDST());
console.log('2022 Summer ISO Time ' + moment.tz(summerDateStr, timeZone).toISOString());
console.log('2022 Summer is DST ' + moment.tz(summerDateStr, timeZone).isDST());
winterDateStr = '2023-12-04T17:05';
summerDateStr = '2023-06-04T17:05';
console.log('2023 Winter ISO Time ' + moment.tz(winterDateStr, timeZone).toISOString());
console.log('2023 Winter is DST ' + moment.tz(winterDateStr, timeZone).isDST());
console.log('2023 Summer ISO Time ' + moment.tz(summerDateStr, timeZone).toISOString());
console.log('2023 Summer is DST ' + moment.tz(summerDateStr, timeZone).isDST());
> 2022 Winter ISO Time 2022-12-05T01:05:00.000Z
2022 Winter is DST false
2022 Summer ISO Time 2022-06-05T00:05:00.000Z
2022 Summer is DST true
2023 Winter ISO Time 2023-12-05T01:05:00.000Z
2023 Winter is DST false
2023 Summer ISO Time 2023-06-05T01:05:00.000Z
2023 Summer is DST false
This also seems related to this similar issue: #6114
from moment.
@ismurray This is weird, but when I ran your code in my own environment, I received the following output:
2022 Winter ISO Time 2022-12-05T01:05:00.000Z
2022 Winter is DST false
2022 Summer ISO Time 2022-06-05T00:05:00.000Z
2022 Summer is DST true
2023 Winter ISO Time 2023-12-05T01:05:00.000Z
2023 Winter is DST false
2023 Summer ISO Time 2023-06-05T00:05:00.000Z
2023 Summer is DST true
I also tried it with 'Europe/Copenhagen' to test @kalina559 's issue and I got:
2022 Winter ISO Time 2022-12-04T16:05:00.000Z
2022 Winter is DST false
2022 Summer ISO Time 2022-06-04T15:05:00.000Z
2022 Summer is DST true
2023 Winter ISO Time 2023-12-04T16:05:00.000Z
2023 Winter is DST false
2023 Summer ISO Time 2023-06-04T15:05:00.000Z
2023 Summer is DST true
Am I perhaps missing something? Could you try running your code again to see if the error is still occurring?
from moment.
@sanchej this may seem like a silly question, but are you potentially using moment-timezone
instead of moment
? I ask because this works correctly for me with moment-timezone
, but not with moment
.
moment:
import moment from 'moment';
// ...
> let timeZone = 'America/Los_Angeles';
let winterDateStr = '2022-12-04T17:05';
let summerDateStr = '2022-06-04T17:05';
console.log('2022 Winter ISO Time ' + moment.tz(winterDateStr, timeZone).toISOString());
console.log('2022 Winter is DST ' + moment.tz(winterDateStr, timeZone).isDST());
console.log('2022 Summer ISO Time ' + moment.tz(summerDateStr, timeZone).toISOString());
console.log('2022 Summer is DST ' + moment.tz(summerDateStr, timeZone).isDST());
winterDateStr = '2023-12-04T17:05';
summerDateStr = '2023-06-04T17:05';
console.log('2023 Winter ISO Time ' + moment.tz(winterDateStr, timeZone).toISOString());
console.log('2023 Winter is DST ' + moment.tz(winterDateStr, timeZone).isDST());
console.log('2023 Summer ISO Time ' + moment.tz(summerDateStr, timeZone).toISOString());
console.log('2023 Summer is DST ' + moment.tz(summerDateStr, timeZone).isDST());
> 2022 Winter ISO Time 2022-12-05T01:05:00.000Z
2022 Winter is DST false
2022 Summer ISO Time 2022-06-05T00:05:00.000Z
2022 Summer is DST true
2023 Winter ISO Time 2023-12-05T01:05:00.000Z
2023 Winter is DST false
2023 Summer ISO Time 2023-06-05T01:05:00.000Z
2023 Summer is DST false
moment-timezone:
import moment from 'moment-timezone';
// ...
let timeZone = 'America/Los_Angeles';
let winterDateStr = '2022-12-04T17:05';
let summerDateStr = '2022-06-04T17:05';
console.log('Winter ISO Time ' + _momentTimezone.tz(winterDateStr, timeZone).toISOString());
console.log('Winter is DST ' + _momentTimezone.tz(winterDateStr, timeZone).isDST());
console.log('Summer ISO Time ' + _momentTimezone.tz(summerDateStr, timeZone).toISOString());
console.log('Summer is DST ' + _momentTimezone.tz(summerDateStr, timeZone).isDST());
winterDateStr = '2023-12-04T17:05';
summerDateStr = '2023-06-04T17:05';
console.log('Winter ISO Time ' + _momentTimezone.tz(winterDateStr, timeZone).toISOString());
console.log('Winter is DST ' + _momentTimezone.tz(winterDateStr, timeZone).isDST());
console.log('Summer ISO Time ' + _momentTimezone.tz(summerDateStr, timeZone).toISOString());
console.log('Summer is DST ' + _momentTimezone.tz(summerDateStr, timeZone).isDST());
> Winter ISO Time 2022-12-05T01:05:00.000Z
Winter is DST false
Summer ISO Time 2022-06-05T00:05:00.000Z
Summer is DST true
Winter ISO Time 2023-12-05T01:05:00.000Z
Winter is DST false
Summer ISO Time 2023-06-05T00:05:00.000Z
Summer is DST true
Versions:
"moment": "2.29.4"
"moment-timezone": "0.5.43"
running in Chrome Version 111.0.5563.146 (Official Build) (arm64)
from moment.
It seems like using moment-timezone might be a solution to our issues, but that would be a significant change in our codebase.
Has anybody been able to find the underlying issue inside of moment.js? I'm not sure how active the team is on this as the project is no longer being developed, and the last update was made about a year ago... the best solution at this point would likely be to fork and patch. @daniellecrasiuc @sanchej @kalina559 @ismurray
from moment.
Hey @ismurray , sorry I was busy but yes I was running moment timezone, I will continue to look into moment
from moment.
@mimen I will continue to look into it, being transparent, I am taking a class that wants us to contribute to an open-source project so I will try to tackle this soon.
from moment.
Moment Timezone includes OLD AND DEPRECATED files called moment-timezone-with-data-2012-2022.js
(and .min.js
). As the filename indicates, they only have data up to and including the year 2022. Given the number of reports of "broken" code as we've hit 2023, I'm guessing that a lot of people are using these files without realising that their code should have been changed years ago. The most recent versions of Moment Timezone have added deprecation warnings to these files, and they'll be completely removed in a future release.
Here are my suggestions for everyone with issues around incorrect DST rules starting this year:
- Check if you're actually using
moment-timezone
, not coremoment
. If your code saysmoment.tz()
, you're usingmoment-timezone
. Coremoment
doesn't include any time zone rules, and just relies on the nativeDate
object. - Check how you're including
moment-timezone
. If you're including a file calledmoment-timezone-with-data-2012-2022.min.js
or similar, this is the problem.- You'll need to change the reference to
moment-timezone-with-data-10-year-range
instead. This is a rolling 10-year range that is updated on every release. For example, any release built in 2023 will include data from 2018 to 2028.
- You'll need to change the reference to
from moment.
Thanks so much @gilmoreorless for providing this info.
For reference for others, I was able to fix this by including this file at the end of my ember-cli-build.js
file.
app.import('node_modules/moment-timezone/builds/moment-timezone-with-data-10-year-range.min.js');
I would suggest that this build should be used by default, but I'm unsure of the implications of that. It seems better than having the default behavior being broken in 2023...
from moment.
Related Issues (20)
- Feb29's month is returning as 2 instead of 1 HOT 5
- moment.tz.guess(true) is not giving the changed time zone as part of DST changes, still giving the actual server time zone with which node application started HOT 1
- Format method is returning YYYY in Spanish locale HOT 1
- Using a Global Initial Date with Moment.js in a React Native Application HOT 1
- 2023-05-26 - 'Deprecation warning: value provided is not in a recognized ISO format. moment construction falls back to js Date()' HOT 2
- Drop your support from BLM from the main web page!
- parseZone() seems to have unexpected handling of ambiguous input HOT 3
- Months and Days = "00" HOT 2
- adding, subtracting, duration problems HOT 1
- subtracting about 131 years HOT 1
- Wrong apostrophe sign used in Ukrainian locale HOT 1
- Add support for startOf(multiple, "interval") or startOf(Duration) to get a beginning of the interval as multiple units #5831 HOT 1
- gets wrong date from date string HOT 3
- valueOf() issues HOT 1
- Language localisation for long date formats. HOT 1
- 2024 - in leap year, March month is not calculating properly HOT 2
- format YYYY-MM-DD issues HOT 1
- New patch version 2.30.0 breaks types toISOString now returns null HOT 9
- Wrong week() and isoWeek() for 2024-12-30 and 31 HOT 1
- Since 2.30.0 TypeError: Cannot read properties of undefined (reading 'setDefault') HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moment.