vault/ui/app/helpers/format-duration.js
Jordan Reimer 5f17953b59
MFA (#14049)
* adds development workflow to mirage config

* adds mirage handler and factory for mfa workflow

* adds mfa handling to auth service and cluster adapter

* moves auth success logic from form to controller

* adds mfa form component

* shows delayed auth message for all methods

* adds new code delay to mfa form

* adds error views

* fixes merge conflict

* adds integration tests for mfa-form component

* fixes auth tests

* updates mfa response handling to align with backend

* updates mfa-form to handle multiple methods and constraints

* adds noDefault arg to Select component

* updates mirage mfa handler to align with backend and adds generator for various mfa scenarios

* adds tests

* flaky test fix attempt

* reverts test fix attempt

* adds changelog entry

* updates comments for todo items

* removes faker from mfa mirage factory and handler

* adds number to word helper

* fixes tests

* Revert "Merge branch 'main' into ui/mfa"

This reverts commit 8ee6a6aaa1, reversing
changes made to 2428dd6cca.

* format-ttl helper fix from main
2022-02-17 09:10:56 -07:00

18 lines
629 B
JavaScript

import { helper } from '@ember/component/helper';
import { formatDuration, intervalToDuration } from 'date-fns';
export function duration([time]) {
// intervalToDuration creates a durationObject that turns the seconds (ex 3600) to respective:
// { years: 0, months: 0, days: 0, hours: 1, minutes: 0, seconds: 0 }
// then formatDuration returns the filled in keys of the durationObject
// time must be in seconds
let duration = Number.parseInt(time, 10);
if (isNaN(duration)) {
return time;
}
return formatDuration(intervalToDuration({ start: 0, end: duration * 1000 }));
}
export default helper(duration);