Skip to content

Commit

Permalink
ensure daily reports dates translate to profile timezone
Browse files Browse the repository at this point in the history
To illustrate the difference, I used chrome "sensors" feature to change my
timezone to one that spans the dateline.

    > moment.tz('2023-01-19', 'America/Los_Angeles').endOf('day').format( )
    '2023-01-19T23:59:59-08:00'
    > moment.tz(moment('2023-01-19'), 'America/Los_Angeles').endOf('day').format( )
    '2023-01-18T23:59:59-08:00'

The old code uses a string replacement, which is equivalent to the first
test.  This causes the dates on the reports to be off by one, as well as
risks the data wrapping around the dateline so it can't be seen.  For example,
replacing "23:59:59" with "00:00:00" in the first example doesn't correctly
wrap around the dateline.

The patch introduces a way to parse the dates requested in the browser's
time zone, and then translates them to the profile's timezone.  The
difference is shown in the second example above.  With this change, the
correct date label should be rendered, and the data should start at
midnight without wrapping around the dateline.
  • Loading branch information
bewest committed Jan 24, 2023
1 parent 0330e13 commit 8983713
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/report/reportclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ var init = function init () {

console.log('DATEFILTER', zone, timerange);
console.log("DATEFILTER", "FROM", from.format( ), moment.tz(moment($('#rp_from').val()).startOf('day'), zone).format( ) );
console.log("DATEFILTER", "TO", to.format( ), moment.tz(moment($('#rp_to').val()).startOf('day'), zone).format( ) );
console.log("DATEFILTER", "TO", to.format( ), moment.tz(moment($('#rp_to').val()).startOf('day'), zone).endOf('day').format( ) );
//console.log($('#rp_from').val(),$('#rp_to').val(),zone,timerange);
while (from <= to) {
if (daystoshow[from.format('YYYY-MM-DD')]) {
Expand Down

0 comments on commit 8983713

Please sign in to comment.