-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
DateInput + Moment-Timezone incompatability #280
Comments
@mfedderly |
@giladgray This isn't a localization problem, Date and Moment disagree on the actual unixtime values that they are representing when moment-timezone has a default timezone that isn't the browser's timezone. |
this sounds like a time localization problem, which is all about timezones (not to be confused with language localization). |
Specifically, it is not a react-day-picker localization problem. |
ok i see what's up now. submit a PR with your functions above! |
After update to 1.2.0 my DateInput doesn't work anymore...with ReduxForm I have a pure function component with DateInput:
before update blueprintjs it wored, now it doesn't works and the error is:
and refer to:
|
@alearcy would you mind filing a new issue for that? we'll try to get it sorted out for the next release. |
BLUF
Using Moment-Timezone's setDefault call, the DateInput UI becomes inconsistent.
Bug report
Steps to reproduce
<DateInput>
element with a specific dateActual behavior
Depending on moment-timezone's configured timezone, and the browser's local timezone, the formatted date disagrees with the calendar date. For instance, if moment-timezone is set to
America/Los_Angeles
and the browser's timezone is set to Hawaii. The formatted date is correct, but the calendar will show a day behind. This has further repercussions when trying to get the time out of onChange as well.Expected behavior
The DateInput correctly handles the timezone disagreement between moment and date.
Possible solution
I have built some quick functions that convert from moment->date that correct for the timezone discrepancy. They should be equivalent to a noop if a default timezone has not been set. The Date being passed into the render
<DatePicker>
and returned intohandleDateChange
can be adjusted with the methods below. It is important to make sure that the DateInputvalue
prop is in the same timezone as the the date returned to theonChange
prop.The text was updated successfully, but these errors were encountered: