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

Parsing dates with a named day of the week fails. #1296

Open
Orbyt opened this issue Dec 31, 2020 · 4 comments
Open

Parsing dates with a named day of the week fails. #1296

Orbyt opened this issue Dec 31, 2020 · 4 comments

Comments

@Orbyt
Copy link

Orbyt commented Dec 31, 2020

Describe the bug
Parsing dates with a named day of the week fails. However, switching the function to call moment works as expected.

const dayjs = require('dayjs')
// Multiple plugins were tested.
let weekday = require('dayjs/plugin/weekday')
let customParseFormat = require('dayjs/plugin/customParseFormat')
let localeData = require('dayjs/plugin/localeData')
let localizedFormat = require('dayjs/plugin/localizedFormat')
let updateLocale = require('dayjs/plugin/updateLocale')
let utc = require('dayjs/plugin/utc')
dayjs.extend(weekday)
dayjs.extend(localeData)
dayjs.extend(customParseFormat)
dayjs.extend(localizedFormat)
dayjs.extend(updateLocale)
dayjs.extend(utc)

// Prints `false`.
console.log(dayjs('Wednesday, December 30th 2020 (6:00 pm)', 'dddd, MMMM Do YYYY (h:mm a)').isValid()) 

// Prints `true`.
var moment = require('moment');
console.log(moment('Wednesday, December 30th 2020 (6:00 pm)', 'dddd, MMMM Do YYYY (h:mm a)').isValid()) 

Information

  • Day.js Version 1.9.8
  • OS: macOS - Node.js
  • Time zone: Pacific
@Orbyt
Copy link
Author

Orbyt commented Dec 31, 2020

#576 appears to have been an attempt to fix a similar issue, but it was never merged.

@ssergeyyy
Copy link

I have the same problem. Any news on this fix? Or is the best way to avoid using dddd with customParseFormat?

@huypxgear
Copy link

I have the same problem. Is there anyway to validate weekday format

@BePo65
Copy link
Contributor

BePo65 commented May 31, 2022

You have 2 problems

  1. 'dddd' is similar to the issue Loading the customParseFormat plugin causes parsing some formats to return invalid dates #1802 - dayjs (and moment too) don't have a dddd parsing format
    This should be a feature request
  2. and the commas in the format are similar to the issue Fix issue #1852 - comma not recognized as a separator character #1913 - dayjs does not accept the comma as a separator character.
    This would be fixed with PR Fix issue #1852 - comma not recognized as a separator character #1913

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

4 participants