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
1st Saturday of Month error for Jan 2023 #6099
Comments
Hey @codedynamics, In short, if you will use It looks like the behavior of the I believe that is related to the way the ISO system treats the day of the week. So, When using When using |
Hi @IvaTsu Thanks for your response and assistance on this. Your reply has helped explain what was going on and also provided a solution! PS. In your last paragraph you mention weekend(6) but I assumed you meant weekday(6) as weekend() is not a function of moment.js |
@codedynamics , edited the original answer. Indeed, I meant |
Describe the bug
Getting 1st Saturday of a Month error with Jan 2023 - returns 31st Dec 2022
Note: works fine for all other months in 2023, eg. for Feb it returns 04 Feb 2023
see example at: http://jsfiddle.net/oja704nq/
To Reproduce
let setMonth = 'Jan';
let setYear = 2023;
let sat_1_date = moment().set('year', setYear).set('month', setMonth).set('date', 1).isoWeekday(6);
console.log(sat_1_date) = Sat Dec 31 2022 13:29:35 GMT+1030 (Australian Central Daylight Time)
Expected behavior
I expected it to return 'Sat Jan 7 2023 13:29:35 GMT+1030 (Australian Central Daylight Time)'
Desktop (please complete the following information):
Moment-specific environment
moment-min.js version 2.29.4
** The time zone setting of the machine the code is running on **
Adelaide, Australia - Australian Central Daylight Time
** The time and date at which the code was run **
System date = 8/02/2023 - 1:29pm
** Please run the following code in your environment and include the output **
console.log((new Date()).toString()) = Wed Feb 08 2023 13:29:35 GMT+1030 (Australian Central Daylight Time)
console.log((new Date()).toLocaleString()) = 08/02/2023, 13:29:35
console.log((new Date()).getTimezoneOffset()) = -630
console.log(navigator.userAgent) = Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
console.log(moment.version) = 2.29.4
Additional context
Note: I also tried using a numerical value for the month, eg. 0 instead of Jan
The text was updated successfully, but these errors were encountered: