-
Notifications
You must be signed in to change notification settings - Fork 838
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
Using a default timezone breaks clone() and startOf() functionality with explicit zones #208
Comments
Agreed. They're both bugs. Cloning a moment shouldn't change anything about it. Any mode, offset, or zone details should carry forward. With regard to Therefore, I would expect: moment.parseZone("2015-03-03T12:00:00+00:00").startOf("day").format() === "2015-03-03T00:00:00+00:00" However, I would expect it to use the time zone rules had you not called moment("2015-03-03T12:00:00+00:00").startOf("day").format() === "2015-03-03T00:00:00+01:00" |
Consider that without moment-timezone, setting my time zone for Brazil: moment("2014-10-19T12:00:00+08:00").startOf('day').format()
// "2014-10-19T01:00:00-02:00"
moment.parseZone("2014-10-19T12:00:00+08:00").startOf('day').format()
// "2014-10-19T00:00:00+08:00" So without moment-timezone appears to have the behavior I described above. It should be the same behavior with |
Indeed, I just found this in the docs:
😄 |
hello, i foun this problem too using moment-with-locales.min.js 2.21.0
when using the "startOf" the timezone is set to zero. temporary solution (force set the timezone again before startOf) :
|
If your time zone is eg Europe/London, this is correct behaviour since DST
started yesterday and the start of the day actually was still in winter
time.
…On Sun, 25 Mar 2018 at 23:26, seltix5 ***@***.***> wrote:
hello,
i foun this problem too using moment-with-locales.min.js 2.21.0
var a = moment();
a.format()
// 2018-03-25T22:14:54+01:00
var b = a.startOf('day');
b.format()
// 2018-03-25T00:00:00+00:00
when using the "startOf" the timezone is set to zero
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#208 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABHo4jqgfGkobFT2_3f22wGMgfnm1xPSks5tiAn4gaJpZM4EKxb0>
.
|
OMG I totally forgot about that! :S you're right! thanks and sorry for the wrong post :/ |
Any news on that? I've been suffering from this and have no idea how to counter it.. |
same here |
@timrwood is it possible to take a look at this one? It's a 3 year old issue that I wasn't able to workaround yet :/ |
Same problem here, still waiting. |
I recommend everyone try upgrading to a newer version of Not 100% sure my issue was the same one anyone here has been having, but I think it may be. |
My browser timezone is CET (+01:00/+02:00).
If not setting an explicit default timezone, stuff works as expected:
When setting an explicit timezone, even dates with explicit zones are set to the default zone when cloned or start-of-day'd
According to the documentation, setDefault should only override what the local timezone is; I would expect a browser with
moment.tz.setDefault("CET");
to behave the same as a browser where the local timezone isCET
. In addition I expectclone()
to give me an exact clone of the object, regardless of default timezones. ForstartOf()
I can understand that behaviour may be not what I expect in this case, however I would expect behaviour to be the same with a local CET timezone and an explicit CET default timezone.The text was updated successfully, but these errors were encountered: