snowballtools-base/packages/frontend/src/utils/time.ts
Nabarun Gogoi bd6a6b330c
Create new deployment on changing preview deployment to production (#61)
* Create new deployment when changing to production

* Remove unnecessary todos

* Move deployment id and url creation in database method

* Display correct details in deployment dialog box

* Rename relativeTime function to relativeTimeISO

* Refactor resolver methods to service class

* Refactor to move github app to service class

---------

Co-authored-by: neeraj <neeraj.rtly@gmail.com>
2024-02-08 14:59:19 +05:30

22 lines
731 B
TypeScript

import { DateTime } from 'luxon';
/**
* Converts an ISO 8601 formatted time to a human-readable relative time with respect to the current time.
*
* @param {string} time - The input time in ISO 8601 format.
* @returns {string} - A human-readable relative time string.
*/
export const relativeTimeISO = (time: string) => {
return DateTime.fromISO(time).toRelative();
};
/**
* Converts time in millisecond format to a human-readable relative time with respect to the current time.
*
* @param {string} time - The input time in millisecond.
* @returns {string} - A human-readable relative time string.
*/
export const relativeTimeMs = (time: string) => {
return relativeTimeISO(new Date(Number(time)).toISOString());
};