question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DateInput test is not passing for other time zones

See original GitHub issue

except for a date-related one because the test doesn’t allow for my +10 timezone.

Expected Behavior

all tests should pass

no errors

Actual Behavior

Different time zones fail the dateinput test Screen Shot 2021-08-24 at 8 20 34 AM

URL, screen shot, or Codepen exhibiting the issue

Steps to Reproduce

Your Environment

  • Grommet version:
  • Browser Name and version:
  • Operating System and version (desktop or mobile):

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
DanielBairdcommented, Aug 25, 2021

I wish I had made this issue when I came across it the first time. From memory the problem is when the “correct” datetime is dinked together as a string with timezoneOffset, which is made like this:

    if (timezoneOffset < 10) timezoneOffset = `0${timezoneOffset}`;

In Australia my timezone is +10, which makes a negative timezoneOffset, but a negative number is less than 10 so it gets prepended with a 0 by that code. Then, subsequent dates assembled like this:

`${year}-${month}-20T${timezoneOffset}:00:00.000Z`,

…are crazy looking.

If I get a chance over the next few weekends I’ll try for a fix. Hopefully I can work out something that works in all timezones but doesn’t require adding Moment or date-fns or whatever to the deps.

Post a comment here if you start working on this so I can ping you and we don’t double up

0reactions
tayseacommented, Nov 3, 2021

I am wondering if we should update this test somehow – it seems part of the issue that has been happening is due to daylight savings timezone. According to this thread, there are functions we could create to see if a caller is in standard time or daylight savings, but according to the discussion under the reply it doesn’t necessarily seem like it’s fully reliable:

https://stackoverflow.com/a/11888430

Read more comments on GitHub >

github_iconTop Results From Across the Web

Components using Date objects produce different snapshots ...
When I run my test in different timezones, this produces different snapshots, because the Date(year, month, ...) constructor creates the date in ...
Read more >
Date input taking into account users time zone offset
I have an input field that is binding to a backing Task in the controller to allow users to enter a date into...
Read more >
How to make date input / date picker display the date as if it ...
How to make date input / date picker display the date as if it was UTC, not local time? 1 Answer 5867 Views....
Read more >
<input type="datetime-local"> - HTML - MDN Web Docs
Setting timezones​​ One thing the datetime-local input type doesn't provide is a way to set the time zone and/or locale of the date/time...
Read more >
Working with Dates, Time, Timezones in GraphQL ... - Hasura
If you are wondering which data type to use for what use case, check out the video from Adron going over the types...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found