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

ddd DD is an invalid format whereas DD, ddd, and ddd YYYY are valid #6228

Open
ashwin-mittal opened this issue Apr 7, 2024 · 0 comments
Open

Comments

@ashwin-mittal
Copy link

Describe the bug
I am getting an invalid moment object for ddd DD format but valid for DD, ddd, and ddd YYYY.

To Reproduce
Steps to reproduce the behavior:

  • I am creating a moment object in UTC for 2015-01-10T01:15Z and converting it into DD, ddd and ddd YYYY format using the format method.
  • Now I converted them back to moment object using non strict parsing for all those formats and got the following results:
ddd Sat true
DD 10 true
ddd DD Sat 10 false
ddd MM Sat 01 false

Expected behavior
Expected behavior would be that ddd DD should also return a valid moment.

Desktop (please complete the following information):

  • OS: macOS Sonoma 14.4.1

Moment-specific environment

  • The time zone setting of the machine the code is running on: IST
  • The time and date at which the code was run: UTC
  • Other libraries in use (TypeScript, Immutable.js, etc): No

Please run the following code in your environment and include the output:

console.log((new Date()).toString())
console.log((new Date()).toLocaleString())
console.log((new Date()).getTimezoneOffset())
console.log(navigator.userAgent)
console.log(moment.version)

Output:

Sun Apr 07 2024 20:24:20 GMT+0530 (India Standard Time)
4/7/2024, 8:24:20 PM
-330
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
2.30.1

Additional context
The code I used to reproduce the issue:

const moment = require('moment');

const formats = ['ddd', 'DD', 'ddd DD', 'ddd YYYY']
for(let format of formats) {
    const d = moment.utc('2015-01-10T01:15Z').format(format)
    console.log(format, d, moment(d, format).isValid())
}
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

1 participant