DateTime with dayjs behaves strangely (wrong format)

DateTime with dayjs behaves strangely (wrong format)

Dennis14eDennis14e Posts: 13Questions: 2Answers: 0

Link to test case:
https://datatables.net/extensions/datetime/examples/initialisation/dayjs
https://github.com/DataTables/DateTime/issues/8

Description of problem:
The behavior of DateTime with Day.js (v1.8.17 on example page, same behaviour with current v1.11.3) seems to be strange.
This strange behavior can also be seen on the example page: https://datatables.net/extensions/datetime/examples/initialisation/dayjs

Environment:
- OS: Arch Linux
- Browser: Google Chrome 103.0.5060.114
- Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7

Steps to reproduce:

Open example page
Choose date 11. July 2022
The input field now says: "11/7/2022", which is correct (based on "format" option)
Click on input field
Selected date is now 6. November 2022

or

Open example page
The input field says "17/1/2020"
Click on input field
Selected date is 17. July 2022 (yesterday)

Answers

  • allanallan Posts: 56,837Questions: 1Answers: 9,033 Site admin

    Thanks for letting me know about this. It is almost certainly a UTC offset error. What timezone are you in?

    I'm traveling this week, but will look into it next.

    Allan

  • Dennis14eDennis14e Posts: 13Questions: 2Answers: 0

    My local timezone currently is UTC+2 (Europe/Berlin).

  • Dennis14eDennis14e Posts: 13Questions: 2Answers: 0

    @allan Any update on this?

  • allanallan Posts: 56,837Questions: 1Answers: 9,033 Site admin

    Not yet sorry. It is on my list, but I've been unwell recently and not done as much as I'd hoped. Hopefully will be on the case next week though.

    Allan

  • Dennis14eDennis14e Posts: 13Questions: 2Answers: 0

    @allen Have you found time to look at the problem so far? The problem is still present for me.

  • allanallan Posts: 56,837Questions: 1Answers: 9,033 Site admin

    Sorry - it's nearly at the top of the list! I just need to wrap up another issue I'm working on.

    Allan

  • allanallan Posts: 56,837Questions: 1Answers: 9,033 Site admin

    Figured it out. Apparently the example also needs the DayJS customParseFormat plug-in loaded as well as the UTC one. With that added in, it works as expected.

    Without it is was treating everything as if it were ISO8601 which is why the results were all over the place.

    Commit for the fix. I'll be updating the site with the fix and issuing a new release sometime in the next few weeks.

    Regards,
    Allan

Sign In or Register to comment.