Skip to content

Commit

Permalink
ensure timezones assigned once in daily reports
Browse files Browse the repository at this point in the history
This fixes the label on the days in the daytoday charts.  Passing a moment
object that is already zoned prevents toLocaleDateString from reinterpreting
the zone information when the date is already relative to the profile.

This also ensures that the datefilter is adjusted to the profile's zone rather
than truncating the time to the end or beginning of the day.  This should
prevent incorrectly wrapping arounnd the dateline.
  • Loading branch information
bewest committed Jan 24, 2023
1 parent a47b367 commit 0330e13
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/report/reportclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ var init = function init () {
var from = moment.tz($('#rp_from').val().replace(/\//g, '-') + 'T00:00:00', zone);
var to = moment.tz($('#rp_to').val().replace(/\//g, '-') + 'T23:59:59', zone);
timerange = '&find[created_at][$gte]=' + from.toISOString() + '&find[created_at][$lt]=' + to.toISOString();

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($('#rp_from').val(),$('#rp_to').val(),zone,timerange);
while (from <= to) {
if (daystoshow[from.format('YYYY-MM-DD')]) {
Expand Down
2 changes: 1 addition & 1 deletion lib/report_plugins/daytoday.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ daytoday.report = function report_daytoday (datastorage, sorteddaystoshow, optio
// create svg and g to contain the chart contents
charts = d3.select('#daytodaychart-' + day).html(
'<b>' +
report_plugins.utils.localeDate(day) +
report_plugins.utils.localeDate(moment(day)) +
'</b><br>'
).append('svg');

Expand Down

0 comments on commit 0330e13

Please sign in to comment.