diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2020-04-01 22:15:08 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2020-04-06 12:50:00 +0200 |
| commit | 7ee073d2453933ed791cceed411f3287016ca0e1 (patch) | |
| tree | a7216d911cda34db8c8a3f69beb18510d9c889ca | |
| parent | 269ba276a3bdd4ef30aeacdc0ace4ed53df8c390 (diff) | |
| download | mullvadvpn-7ee073d2453933ed791cceed411f3287016ca0e1.tar.xz mullvadvpn-7ee073d2453933ed791cceed411f3287016ca0e1.zip | |
Display time left in days if less than three months
| -rw-r--r-- | gui/src/shared/account-expiry.ts | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/gui/src/shared/account-expiry.ts b/gui/src/shared/account-expiry.ts index 95257bda28..44c62a613e 100644 --- a/gui/src/shared/account-expiry.ts +++ b/gui/src/shared/account-expiry.ts @@ -22,7 +22,22 @@ export default class AccountExpiry { } public durationUntilExpiry(): string { - return this.expiry.fromNow(true); + const daysDiff = this.expiry.diff(new Date(), 'days'); + + // Below three months we want to show the duration in days. Moments fromNow() method starts + // measuring duration in months from 26 days and up. + // https://momentjs.com/docs/#/displaying/fromnow/ + if (daysDiff >= 26 && daysDiff <= 90) { + return sprintf( + // TRANSLATORS: The remaining time left on the account measured in days. + // TRANSLATORS: Available placeholders: + // TRANSLATORS: %(duration)s - The remaining time measured in days. + messages.pgettext('account-expiry', '%(duration)s days'), + { duration: daysDiff }, + ); + } else { + return this.expiry.fromNow(true); + } } public remainingTime(): string { |
