From 3d826fff41d744806e1e0c9d3bdceb395f1ce2ae Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Mon, 19 Sep 2016 16:20:34 -0700 Subject: [PATCH] =?UTF-8?q?fix(trial):=20Compute=20=E2=80=9Cdays=20remaini?= =?UTF-8?q?ng=E2=80=9D=20in=20timezone-aware=20way?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/flux/stores/identity-store.es6 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/flux/stores/identity-store.es6 b/src/flux/stores/identity-store.es6 index d942b9f86..72446edb6 100644 --- a/src/flux/stores/identity-store.es6 +++ b/src/flux/stores/identity-store.es6 @@ -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 = () => {