mirror of https://github.com/status-im/fathom.git
convert unix timestamps to local timezone for chart x-axes. fixes #39
This commit is contained in:
parent
bf817eff8e
commit
f822dbbdb7
|
@ -41,8 +41,10 @@ var timeFormatPicker = function (formats, len) {
|
|||
};
|
||||
|
||||
function prepareData(startUnix, endUnix, data) {
|
||||
let startDate = new Date(startUnix * 1000);
|
||||
let endDate = new Date(endUnix * 1000);
|
||||
// add timezone offset back in to get local start date
|
||||
const timezoneOffset = (new Date()).getTimezoneOffset() * 60;
|
||||
let startDate = new Date((startUnix + timezoneOffset) * 1000);
|
||||
let endDate = new Date((endUnix+timezoneOffset) * 1000);
|
||||
let datamap = [];
|
||||
let newData = [];
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ class DatePicker extends Component {
|
|||
let before, after;
|
||||
before = Math.round(((+endDate) / 1000) - timezoneOffset);
|
||||
after = Math.round(((+startDate) / 1000) - timezoneOffset);
|
||||
|
||||
this.setState({
|
||||
period: period || '',
|
||||
startDate: startDate,
|
||||
|
@ -93,6 +94,7 @@ class DatePicker extends Component {
|
|||
after: after,
|
||||
});
|
||||
|
||||
// use slight delay for updating rest of application to allow this function to be called again
|
||||
if(!this.timeout) {
|
||||
this.timeout = window.setTimeout(() => {
|
||||
this.props.onChange(this.state);
|
||||
|
|
Loading…
Reference in New Issue