-
Notifications
You must be signed in to change notification settings - Fork 116
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
Issue #353: Date Ranges should honour timezone settings. #370
Conversation
The problem here is that the date picker uses the date of the visitor’s computer. This means that we have to take the site GMT offset, and add the local computer’s GMT offset, and then compare the current date with the offset date.
@@ -171,6 +171,7 @@ public static function admin_enqueue_scripts( $hook ) { | |||
'confirm_purge' => __( 'Are you sure you want to delete all Stream activity records from the database? This cannot be undone.', 'stream' ), | |||
'confirm_uninstall' => __( 'Are you sure you want to uninstall and deactivate Stream? This will delete all Stream tables from the database and cannot be undone.', 'stream' ), | |||
), | |||
'gmt_offset' => get_option('gmt_offset'), |
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.
@lukecarbis Travis is failing due to lack of spacing in this line: get_option( 'gmt_offset' )
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.
#OMGBBQ 😉
@lukecarbis Unfortunately, this PR isn't quite working for me yet.
|
@fjarrett @lukecarbis I had this same javascript offset problem on some scheduling feature I worked on. I'm adding the code I had to use to get it working right in case it might help here.
This relied on the getOffset method which just converted the users timezone to + - hours from UTC then checking if it's daylight savings using this function and adding the extra hour if true.
Another function that used some of the built in datepicker methods:
|
@c3mdigital Thanks! @fjarrett Good pickup. I hadn't thought to test the dropdown menu, I was only looking at the datepicker fields. |
@lukecarbis When I select Yesterday from the dropdown the start date is correct, but the end date is incorrect. |
Okay - I've found a better way of implementing timezone support in carbon. I had to get the wordpress timezone string (e.g. Australia/Brisbane) but if it didn't exist (e.g. GMT +10), then I had to search for the string based on the offset. |
Issue #353: Date Ranges should honour timezone settings.
The problem here is that the date picker uses the date of the visitor’s
computer. This means that we have to take the site GMT offset, and add
the local computer’s GMT offset, and then compare the current date with
the offset date.
Resolves #353