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

"moment().add(1,'d')" doesn't behave as expected around timezone changes #676

Closed
jodevsa opened this issue Oct 5, 2018 · 2 comments
Closed

Comments

@jodevsa
Copy link

jodevsa commented Oct 5, 2018

Hi there,

After reviewing an issue in Cron; a library that utilizes moment-timezone for time zone support. We were able to trace it back to the unexpected behavior occurring from reading date.days() value after triggering date.add(1,'d')`

Steps to reproduce:

const moment = require('moment-timezone');
const date= moment.tz(new Date("Sat Nov 03 2018 00:00:00 GMT-0300"),"America/Sao_Paulo")
console.log(date.days());
console.log(date.toString()); // outputs: Sat Nov 03 2018 00:00:00 GMT-0300
date.add(1,'d');
console.log(date.days())
console.log(date.toString())  // outputs: Sat Nov 03 2018 23:00:00 GMT-0300 but should be  Sat Nov 04 2018 00:00:00 GMT-0200


@jodevsa jodevsa changed the title "moment.add(1,'d')" doesn't behaving as expected with "America/Sao_Paulo" timezone "moment().add(1,'d')" doesn't behaving as expected with "America/Sao_Paulo" timezone Oct 5, 2018
@jodevsa jodevsa changed the title "moment().add(1,'d')" doesn't behaving as expected with "America/Sao_Paulo" timezone "moment().add(1,'d')" doesn't behave as expected around timezone changes Oct 5, 2018
@jodevsa
Copy link
Author

jodevsa commented Oct 5, 2018

I understand that this might be due to timezone changes but even date.day() remain unchanged after the add

@mattjohnsonpint
Copy link
Contributor

Duplicate of #409. Tracking there. Thanks.

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

2 participants