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

Adding a day to April 1st not working #262

Closed
alebenson opened this issue Jun 27, 2018 · 7 comments
Closed

Adding a day to April 1st not working #262

alebenson opened this issue Jun 27, 2018 · 7 comments

Comments

@alebenson
Copy link

I'm trying to add 1 day from the first of April to get Monday, 02 Apr 18, and I get the same date.

console.log( dayjs("2018-02-01").add(0,"day").format("dddd, DD MMM YY") ) // Thursday, 01 Feb 18
console.log( dayjs("2018-02-01").add(1,"day").format("dddd, DD MMM YY") ) // Friday, 02 Feb 18
console.log( dayjs("2018-03-01").add(0,"day").format("dddd, DD MMM YY") ) // Thursday, 01 Mar 18
console.log( dayjs("2018-03-01").add(1,"day").format("dddd, DD MMM YY") ) // Friday, 02 Mar 18

console.log( dayjs("2018-04-01").add(0,"day").format("dddd, DD MMM YY") ) // Sunday, 01 Apr 18
console.log( dayjs("2018-04-01").add(1,"day").format("dddd, DD MMM YY") ) // Sunday, 01 Apr 18 *
console.log( dayjs("2018-04-01").add(2,"day").format("dddd, DD MMM YY") ) // Monday, 02 Apr 18

console.log( dayjs("2018-05-01").add(0,"day").format("dddd, DD MMM YY") ) // Tuesday, 01 May 18
console.log( dayjs("2018-05-01").add(1,"day").format("dddd, DD MMM YY") ) // Wednesday, 02 May 18
console.log( dayjs("2018-06-01").add(0,"day").format("dddd, DD MMM YY") ) // Friday, 01 Jun 18
console.log( dayjs("2018-06-01").add(1,"day").format("dddd, DD MMM YY") ) // Saturday, 02 Jun 18
@iamkun
Copy link
Owner

iamkun commented Jun 27, 2018

@alebenson Seems ok to me. https://runkit.com/embed/szquqbtnx2rh

Any other information you could provide?

@alebenson
Copy link
Author

@iamkun your sample is working for us but when we try to do the same on RunKit, we get the same output as the first message.

https://runkit.com/embed/r9j51zfzg7kr
node v8.11.3
dayjs 1.6.10

var dayjs = require("dayjs")
console.log(dayjs("2018-04-01").add(1,"day").format("dddd, DD MMM YY")) // Sunday, 01 Apr 18
console.log(dayjs("2018-04-01").add(2,"day").format("dddd, DD MMM YY")) // Monday, 02 Apr 18

https://jsfiddle.net/pxw7gumo/
using: https://cdn.jsdelivr.net/npm/dayjs@1.6.10/dayjs.min.js

console.log(dayjs("2018-04-01").add(1,"day").format("dddd, DD MMM YY")) // Sunday, 01 Apr 18
console.log(dayjs("2018-04-01").add(2,"day").format("dddd, DD MMM YY")) // Monday, 02 Apr 18

@iamkun
Copy link
Owner

iamkun commented Jun 28, 2018

@alebenson Interesting. Your timezone, DST please?

@alebenson
Copy link
Author

@alebenson
Copy link
Author

Hello @iamkun any update on this or a workaround?

@LexSwed LexSwed mentioned this issue Sep 6, 2018
@prantlf
Copy link
Contributor

prantlf commented Sep 13, 2018

@alebenson, you could use the raw Date with setUTCDate as a workaround. If you want a workaround for dayjs instances, you could need to check, if the day really changed and add 2 days, if it did not. Clumsy, isn't it ;-) You can also try PRs #168 and #326 as a cleaner workaround.

Otherwise you case appears to be the same, as I commented about at the issue #329 and similar to the others, who assume, that there's something like a "date-only mode" (#249 and #74).

@iamkun iamkun closed this as completed in 969aced Sep 26, 2018
@iamkun
Copy link
Owner

iamkun commented Sep 26, 2018

@alebenson You may could try v1.7.7 and check if this issue is fixed in your timezone. THX.

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

3 participants