Open cypressious opened 3 years ago
dayjs('8. Dez 2020 15:22', { format: 'D. MMM YYYY HH:mm'})
is not listed on the doc.
please use dayjs('8. Dez 2020 15:22', 'D. MMM YYYY HH:mm') instead
Shouldn't it be removed from the type definitions then?
I just stumbled upon the issue.
import dayjs from 'dayjs';
import dayJsCustomParseFormat from 'dayjs/plugin/customParseFormat';
describe('Dates parsing', () => {
beforeAll(() => {
dayjs.extend(dayJsCustomParseFormat);
});
it('should parse equally', () => {
const result1 = dayjs('08.04.2011', 'DD.MM.YYYY');
const result2 = dayjs('08.04.2011', { format: 'DD.MM.YYYY' });
expect(result1).toEqual(result2);
// - Expected - 1
// + Received + 1
// - "2011-08-03T20:00:00.000Z"
// + "2011-04-07T20:00:00.000Z"
});
});
What if I also need to pass utc: true
with format? I don't see the way to do it without using OptionType as an object.
Describe the bug I'm using the following plugins:
The TypeScript declarations (extract below) suggest that the
dayjs()
function accepts the second parameter in the object form{ locale?: string, format?: string, utc?: boolean }
.However, calling
dayjs('8. Dez 2020 15:22', { format: 'D. MMM YYYY HH:mm'})
returns an invalid date whereasdayjs('8. Dez 2020 15:22', 'D. MMM YYYY HH:mm')
returns a parsed date.Expected behavior Calling
dayjs('8. Dez 2020 15:22', { format: 'D. MMM YYYY HH:mm'})
returns a parsed date.Information