CustomParseFormat does't use a timezone
Describe the bug
When using input format as array then output format does't take specified timezone.
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import customParseFormat from 'dayjs/plugin/customParseFormat';
import timezone from 'dayjs/plugin/timezone';
dayjs.extend(utc);
dayjs.extend(timezone);
dayjs.extend(customParseFormat);
dayjs.tz.setDefault('Europe/Moscow');
// Incorrect, output:
// 31.05.2021 21:00
console.log(
dayjs
.tz('01.06.2021 00:00', ['DD.MM.YYYY HH:mm'], 'Europe/Moscow')
.format('DD.MM.YYYY HH:mm'),
);
Expected behavior
When using just a string for input format the timezone takes correctly.
// Correct, output:
// 01.06.2021 00:00
console.log(
dayjs
.tz('01.06.2021 00:00', 'DD.MM.YYYY HH:mm', 'Europe/Moscow')
.format('DD.MM.YYYY HH:mm'),
);
Information
- Day.js Version: v1.10.7
- OS: macOS 12.0.1 (21A559)
- Browser: NodeJS v15.14.0
- Time zone: GMT+03:00
Links
- Doc about format: https://day.js.org/docs/en/parse/string-format
- PR with supports of array for format: https://github.com/iamkun/dayjs/pull/906/files
yes, I met the same problem. Any fix?
I could reproduce the issue even with the current version (v1.11.2). I am preparing a PR for issue #1596, which solves even this problem. So I expect that this problem will be solved not too far in the future ;-)
https://github.com/iamkun/dayjs/issues/944 https://github.com/iamkun/dayjs/pull/1914 I hope that these issues, including this one, will be resolved.