mirror of https://github.com/status-im/fathom.git
get rid of timezone offset as we're already populating date object from timestamp
This commit is contained in:
parent
5ef2b166ab
commit
86e50ca573
|
@ -52,9 +52,9 @@ function timeFormatPicker(n) {
|
||||||
|
|
||||||
function prepareData(startUnix, endUnix, data) {
|
function prepareData(startUnix, endUnix, data) {
|
||||||
// add timezone offset back in to get local start date
|
// add timezone offset back in to get local start date
|
||||||
const timezoneOffset = (new Date()).getTimezoneOffset() * 60;
|
//const timezoneOffset = (new Date()).getTimezoneOffset() * 60;
|
||||||
let startDate = new Date((startUnix + timezoneOffset) * 1000);
|
let startDate = new Date((startUnix) * 1000);
|
||||||
let endDate = new Date((endUnix+timezoneOffset) * 1000);
|
let endDate = new Date((endUnix) * 1000);
|
||||||
let datamap = [];
|
let datamap = [];
|
||||||
let newData = [];
|
let newData = [];
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ function prepareData(startUnix, endUnix, data) {
|
||||||
d = data[i];
|
d = data[i];
|
||||||
// replace date with actual date object & store in datamap
|
// replace date with actual date object & store in datamap
|
||||||
dateParts = d.Date.split('T')[0].split('-');
|
dateParts = d.Date.split('T')[0].split('-');
|
||||||
date = new Date(dateParts[0], dateParts[1]-1, dateParts[2], 0, 0, 0)
|
date = new Date(Date.UTC(dateParts[0], dateParts[1]-1, dateParts[2], 0, 0, 0))
|
||||||
key = date.getFullYear() + "-" + padZero(date.getMonth() + 1) + "-" + padZero(date.getDate());
|
key = date.getFullYear() + "-" + padZero(date.getMonth() + 1) + "-" + padZero(date.getDate());
|
||||||
d.Date = date;
|
d.Date = date;
|
||||||
datamap[key] = d;
|
datamap[key] = d;
|
||||||
|
|
|
@ -46,7 +46,6 @@ const availablePeriods = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const timezoneOffset = (new Date()).getTimezoneOffset() * 60;
|
|
||||||
const padZero = function(n){return n<10? '0'+n:''+n;}
|
const padZero = function(n){return n<10? '0'+n:''+n;}
|
||||||
|
|
||||||
class DatePicker extends Component {
|
class DatePicker extends Component {
|
||||||
|
@ -55,10 +54,10 @@ class DatePicker extends Component {
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
period: props.value,
|
period: props.value,
|
||||||
before: 0,
|
before: 0, // UTC timestamp
|
||||||
after: 0,
|
after: 0, // UTC timestamp
|
||||||
startDate: null,
|
startDate: null, // local date object
|
||||||
endDate: null,
|
endDate: null, // local date object
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateDatesFromPeriod(this.state.period)
|
this.updateDatesFromPeriod(this.state.period)
|
||||||
|
@ -87,8 +86,8 @@ class DatePicker extends Component {
|
||||||
|
|
||||||
// create unix timestamps from local date objects
|
// create unix timestamps from local date objects
|
||||||
let before, after;
|
let before, after;
|
||||||
before = Math.round(((+endDate) / 1000) - timezoneOffset);
|
before = Math.round((+endDate) / 1000);
|
||||||
after = Math.round(((+startDate) / 1000) - timezoneOffset);
|
after = Math.round((+startDate) / 1000);
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
period: period || '',
|
period: period || '',
|
||||||
|
|
Loading…
Reference in New Issue