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

CustomParseFormat does't use a timezone #1750

Open
tenorok opened this issue Dec 26, 2021 · 2 comments
Open

CustomParseFormat does't use a timezone #1750

tenorok opened this issue Dec 26, 2021 · 2 comments

Comments

@tenorok
Copy link

tenorok commented Dec 26, 2021

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

@Haixing-Hu
Copy link

yes, I met the same problem. Any fix?

@BePo65
Copy link
Contributor

BePo65 commented May 25, 2022

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 ;-)

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

3 participants