-
Notifications
You must be signed in to change notification settings - Fork 7
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
fix(vizBuilder): RN-1054: picks wrong date #5447
Conversation
avoids typing issues where return type could be `null`
Importing from `tsutils` to front-end packages is problematic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, looks great. I have a couple of pedantic suggestions, but I'm happy to pre-approve
packages/admin-panel/src/VizBuilderApp/components/PreviewOptions.jsx
Outdated
Show resolved
Hide resolved
packages/admin-panel/src/VizBuilderApp/components/PreviewOptions.jsx
Outdated
Show resolved
Hide resolved
merge latest dev before testing
merge latest dev before testing
merge latest dev
# Conflicts: # packages/admin-panel/src/VizBuilderApp/components/PreviewOptions.jsx
merge latest dev before testing
/** | ||
* When you select a date in the date picker (either with the interactive calendar or by inserting | ||
* a valid date string), the picker actually selects a specific moment in time on that date with | ||
* the normal, millisecond granularity of a Date object. The time of day it selects is the current | ||
* local time on the system where VizBuilder is running. | ||
* | ||
* When inputting the date, the date picker interprets it in the user’s time zone. Under the hood, | ||
* this is converted to UTC. But since we only need day-level granularity, this timezone | ||
* conversion can make the date picker select a date different from what the user input (±1 day) | ||
* when {@link converDateToIsoString} discards the timestamp. | ||
* | ||
* This helper function accounts for that discrepancy. | ||
* | ||
* @param date A valid date object | ||
* @returns {Date} | ||
*/ | ||
const shiftEpoch = date => | ||
new Date(date.setMinutes(date.getMinutes() - date.getTimezoneOffset())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexd-bes This is the hacky fix I mentioned in stand-up this morning. Easy enough to understand, but you can imagine why I’m not happy about it 😅
Andrew went to the trouble of testing at multiple times throughout the day and it does seem to work, though; so it’s currently marked as test passed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is probably fine - as you say, it's a very specific case and it's an old install of datepicker which may get rejigged anyway, so if it works it's all good
Issue RN-1054: Fix Viz Buidler Date Picker behaviour
Changes
Fixes behaviour in Viz Builder where date picker would select a date and time (with a deterministic-but-unpredictable time), which resulted in unexpected query results
The nitty-gritty
fetchReportPreviewData
endpoint with full ISO timestamps (date and time) in Zulu time, usually converted from whatever the user’s browser’s local time was (this behaviour seems to vary between browsers/runtime environments).Date
object in back-end (which introduces timezone conversion issues), and back into string forDataTableService
’s consumption.