Parsing dates with a named day of the week fails.
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
https://github.com/iamkun/dayjs/pull/576 appears to have been an attempt to fix a similar issue, but it was never merged.
I have the same problem. Any news on this fix? Or is the best way to avoid using dddd with customParseFormat?
I have the same problem. Is there anyway to validate weekday format
You have 2 problems
- 'dddd' is similar to the issue #1802 - dayjs (and moment too) don't have a
ddddparsing format
This should be a feature request - and the commas in the format are similar to the issue #1913 - dayjs does not accept the comma as a separator character.
This would be fixed with PR #1913
Hi @iamkun, Any news on this please ? :pray: Thank you