mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-14 20:21:26 +08:00
fix(trial): Compute “days remaining” in timezone-aware way
This commit is contained in:
parent
0891ad855d
commit
3d826fff41
1 changed files with 7 additions and 1 deletions
|
@ -3,6 +3,7 @@ import keytar from 'keytar';
|
|||
import {ipcRenderer, remote} from 'electron';
|
||||
import request from 'request';
|
||||
import url from 'url'
|
||||
import Moment from 'moment-timezone';
|
||||
|
||||
import Actions from '../actions';
|
||||
import AccountStore from './account-store';
|
||||
|
@ -93,7 +94,12 @@ class IdentityStore extends NylasStore {
|
|||
if (!this._subscriptionRequiredAfter) {
|
||||
return null;
|
||||
}
|
||||
return Math.max(0, Math.round((this._subscriptionRequiredAfter.getTime() - Date.now()) / (1000 * 24 * 60 * 60)));
|
||||
const now = new Moment();
|
||||
const nowDayOfEpoch = now.dayOfYear() + now.year() * 365;
|
||||
const requiredAt = new Moment(this._subscriptionRequiredAfter);
|
||||
const requiredDayOfEpoch = requiredAt.dayOfYear() + requiredAt.year() * 365;
|
||||
|
||||
return Math.max(0, requiredDayOfEpoch - nowDayOfEpoch);
|
||||
}
|
||||
|
||||
refreshStatus = () => {
|
||||
|
|
Loading…
Reference in a new issue