2021-04-28 07:41:20 -04:00
|
|
|
import moment from 'moment'
|
|
|
|
|
|
|
|
moment.updateLocale('en', {
|
|
|
|
calendar: {
|
|
|
|
lastDay: '[Yesterday]',
|
|
|
|
sameDay: '[Today]',
|
|
|
|
nextDay: '[Tomorrow]',
|
|
|
|
lastWeek: 'ddd, Do MMM YY',
|
|
|
|
nextWeek: 'ddd, Do MMM YY',
|
|
|
|
sameElse: 'ddd, Do MMM YY',
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2023-04-11 04:35:33 -04:00
|
|
|
export function formatTime(date, format = 'h:mm a') {
|
|
|
|
return moment(date).format(format)
|
2021-04-28 07:41:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export function relativeDate(date) {
|
|
|
|
return moment(date).calendar()
|
|
|
|
}
|
2023-05-02 07:58:01 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {string} isoTimestamp
|
|
|
|
* @returns {number}
|
|
|
|
*/
|
|
|
|
export function isoToUnix(isoTimestamp) {
|
|
|
|
const unixTimestamp = Date.parse(isoTimestamp) / 1000
|
|
|
|
return unixTimestamp
|
|
|
|
}
|