diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2019-03-04 14:34:55 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2019-03-07 13:48:30 +0100 |
| commit | a11205b5fc5bc1b2140c530a372b449717794e2f (patch) | |
| tree | 4698dbc79a38d17b1ea7524abdef057c8fbaeae6 /gui/src/renderer/lib | |
| parent | 99ea926d8e9d529bd579ca79b15eb14ac7b87b00 (diff) | |
| download | mullvadvpn-a11205b5fc5bc1b2140c530a372b449717794e2f.tar.xz mullvadvpn-a11205b5fc5bc1b2140c530a372b449717794e2f.zip | |
Refactor code
Diffstat (limited to 'gui/src/renderer/lib')
| -rw-r--r-- | gui/src/renderer/lib/account-expiry.ts | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/gui/src/renderer/lib/account-expiry.ts b/gui/src/renderer/lib/account-expiry.ts index e781caeffe..5a8e5e8ec2 100644 --- a/gui/src/renderer/lib/account-expiry.ts +++ b/gui/src/renderer/lib/account-expiry.ts @@ -5,16 +5,20 @@ import { pgettext } from '../../shared/gettext'; export default class AccountExpiry { private expiry: moment.Moment; - constructor(expiry: string) { - this.expiry = moment(expiry); + constructor(isoString: string, locale: string) { + this.expiry = moment(isoString).locale(locale); } public hasExpired(): boolean { - return this.willHaveExpiredIn(moment()); + return this.willHaveExpiredAt(new Date()); } - public willHaveExpiredIn(time: moment.Moment): boolean { - return this.expiry.isSameOrBefore(time); + public willHaveExpiredAt(date: Date): boolean { + return this.expiry.isSameOrBefore(date); + } + + public formattedDate(): string { + return this.expiry.format('L LTS'); } public remainingTime(): string { |
