Skip to content

Commit

Permalink
unstaked period says 10 days
Browse files Browse the repository at this point in the history
  • Loading branch information
Viterbo committed May 10, 2024
1 parent 2fbe266 commit 353a837
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/antelope/stores/rex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export const useRexStore = defineStore(store_name, {
state.__rexData[label]?.period ?? null,
// translation function only takes the key name, without the path and adds the prefix
(key:string) => getAntelope().config.localizationHandler(`antelope.words.${key}`),
// force to show days instead of being dynamic,
'days',
// force to round the number
true,
),

},
Expand Down
12 changes: 6 additions & 6 deletions src/antelope/stores/utils/date-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,27 @@ export function dateIsWithinXMinutes(epochMs: number, minutes: number) {
* @param {function} $t translation function. Should accept a string (just the keyname without a path) and return a translated string
* @returns {string} plain english time period
*/
export function prettyTimePeriod(seconds: number|null, $t: (key: string) => string, round = false) {
export function prettyTimePeriod(seconds: number|null, $t: (key: string) => string, units = '', round = false) {
if (seconds === null) {
return '--';
}

let quantity;
let unit;

if (seconds < HOUR_SECONDS) {
if (seconds < HOUR_SECONDS || units === 'minutes') {
quantity = seconds / MINUTE_SECONDS;
unit = $t('minutes');
} else if (seconds < DAY_SECONDS) {
} else if (seconds < DAY_SECONDS || units === 'hours') {
quantity = seconds / HOUR_SECONDS;
unit = $t('hours');
} else if (seconds < WEEK_SECONDS) {
} else if (seconds < WEEK_SECONDS || units === 'days') {
quantity = seconds / DAY_SECONDS;
unit = $t('days');
} else if (seconds < MONTH_SECONDS) {
} else if (seconds < MONTH_SECONDS || units === 'weeks') {
quantity = seconds / WEEK_SECONDS;
unit = $t('weeks');
} else if (seconds < YEAR_SECONDS) {
} else if (seconds < YEAR_SECONDS || units === 'months') {
quantity = seconds / MONTH_SECONDS;
unit = $t('months');
} else {
Expand Down

0 comments on commit 353a837

Please sign in to comment.