From a8ce269bda5df4dc83ef6e29456f086e774b917c Mon Sep 17 00:00:00 2001 From: Goutte Date: Wed, 20 Dec 2017 19:17:41 +0100 Subject: [PATCH] Force time display to be UTC (whatever the user's locale is) --- web/static/js/swapp.js | 22 +++++++++++----------- web/static/js/swapp.ls | 22 +++++++++++----------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/web/static/js/swapp.js b/web/static/js/swapp.js index 2ecc0a9..d125fe7 100644 --- a/web/static/js/swapp.js +++ b/web/static/js/swapp.js @@ -183,7 +183,7 @@ return d3.csv(url, function(csv){ var timeFormat, data; console.debug("Requested CSV for " + target_slug + "…", csv); - timeFormat = d3.timeParse('%Y-%m-%dT%H:%M:%S%Z'); + timeFormat = d3.utcParse('%Y-%m-%dT%H:%M:%S%Z'); data = { 'hee': [] }; @@ -497,16 +497,16 @@ bottom: 30, left: 80 }; - this.xScale = d3.scaleTime().domain(this.xDataExtent); + this.xScale = d3.scaleUtc().domain(this.xDataExtent); this.yScale = d3.scaleLinear().domain(this.yDataExtent); - formatMillisecond = d3.timeFormat(".%L"); - formatSecond = d3.timeFormat(":%S"); - formatMinute = d3.timeFormat("%H:%M"); - formatHour = d3.timeFormat("%H:%M"); - formatDay = d3.timeFormat("%a %d"); - formatWeek = d3.timeFormat("%b %d"); - formatMonth = d3.timeFormat("%B"); - formatYear = d3.timeFormat("%Y"); + formatMillisecond = d3.utcFormat(".%L"); + formatSecond = d3.utcFormat(":%S"); + formatMinute = d3.utcFormat("%H:%M"); + formatHour = d3.utcFormat("%H:%M"); + formatDay = d3.utcFormat("%a %d"); + formatWeek = d3.utcFormat("%b %d"); + formatMonth = d3.utcFormat("%B"); + formatYear = d3.utcFormat("%Y"); multiFormat = function(date){ if (date > d3.timeSecond(date)) { return formatMillisecond(date); @@ -721,7 +721,7 @@ TimeSeries.prototype.bisectDate = d3.bisector(function(d){ return d.x; }).left; - TimeSeries.prototype.timeFormat = d3.timeFormat("%Y-%m-%d %H:%M"); + TimeSeries.prototype.timeFormat = d3.utcFormat("%Y-%m-%d %H:%M"); TimeSeries.prototype.moveCursor = function(x0){ var i, d0, d1, d, xx, yy, mirrored, dx, transform; i = this.bisectDate(this.data, x0, 1); diff --git a/web/static/js/swapp.ls b/web/static/js/swapp.ls index f0c7071..aa173c1 100644 --- a/web/static/js/swapp.ls +++ b/web/static/js/swapp.ls @@ -159,7 +159,7 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE url = sw.buildDataUrlForTarget(target_slug, started_at, stopped_at) d3.csv(url, (csv) -> console.debug("Requested CSV for #{target_slug}…", csv) - timeFormat = d3.timeParse('%Y-%m-%dT%H:%M:%S%Z') + timeFormat = d3.utcParse('%Y-%m-%dT%H:%M:%S%Z') data = { 'hee': [] } configuration['parameters'].forEach((parameter) -> data[parameter['id']] = [] @@ -384,19 +384,19 @@ export class TimeSeries left: 80 } - @xScale = d3.scaleTime().domain(@xDataExtent) + @xScale = d3.scaleUtc().domain(@xDataExtent) @yScale = d3.scaleLinear().domain(@yDataExtent) # Domain on a log scale MUST NOT cross zero # @yScale = d3.scaleLog().domain(@yDataExtent) - formatMillisecond = d3.timeFormat(".%L") - formatSecond = d3.timeFormat(":%S") - formatMinute = d3.timeFormat("%H:%M") - formatHour = d3.timeFormat("%H:%M") - formatDay = d3.timeFormat("%a %d") - formatWeek = d3.timeFormat("%b %d") - formatMonth = d3.timeFormat("%B") - formatYear = d3.timeFormat("%Y") + formatMillisecond = d3.utcFormat(".%L") + formatSecond = d3.utcFormat(":%S") + formatMinute = d3.utcFormat("%H:%M") + formatHour = d3.utcFormat("%H:%M") + formatDay = d3.utcFormat("%a %d") + formatWeek = d3.utcFormat("%b %d") + formatMonth = d3.utcFormat("%B") + formatYear = d3.utcFormat("%Y") multiFormat = (date) -> if date > d3.timeSecond(date) then return formatMillisecond(date) @@ -645,7 +645,7 @@ export class TimeSeries @focus.style("display", "none") bisectDate: d3.bisector((d) -> d.x).left # /!\ complex - timeFormat: d3.timeFormat("%Y-%m-%d %H:%M") + timeFormat: d3.utcFormat("%Y-%m-%d %H:%M") moveCursor: (x0) -> i = @bisectDate(@data, x0, 1) -- libgit2 0.21.2