summaryrefslogtreecommitdiffhomepage
path: root/gui/src/shared
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2020-04-06 13:05:42 +0200
committerOskar Nyberg <oskar@mullvad.net>2020-04-06 13:05:42 +0200
commit7d61c0f2231ebd7222f3c8be875e274d49ee3e26 (patch)
treea7216d911cda34db8c8a3f69beb18510d9c889ca /gui/src/shared
parente3f575f0ca0289a4fc4e1c482bfb23cb30d2b979 (diff)
parent7ee073d2453933ed791cceed411f3287016ca0e1 (diff)
downloadmullvadvpn-7d61c0f2231ebd7222f3c8be875e274d49ee3e26.tar.xz
mullvadvpn-7d61c0f2231ebd7222f3c8be875e274d49ee3e26.zip
Merge branch 'change-time-format'
Diffstat (limited to 'gui/src/shared')
-rw-r--r--gui/src/shared/account-expiry.ts19
1 files changed, 17 insertions, 2 deletions
diff --git a/gui/src/shared/account-expiry.ts b/gui/src/shared/account-expiry.ts
index 8e4c9b2ece..44c62a613e 100644
--- a/gui/src/shared/account-expiry.ts
+++ b/gui/src/shared/account-expiry.ts
@@ -18,11 +18,26 @@ export default class AccountExpiry {
}
public formattedDate(): string {
- return this.expiry.format('L LTS');
+ return this.expiry.format('lll');
}
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 {