overleaf/services/web/frontend/js/features/utils/format-date.js
ilkin-overleaf 5480e1b371 Merge pull request #12850 from overleaf/ii-history-react-fix-disappeared-pseudo-labels
[web] Fix disappeared pseudo labels

GitOrigin-RevId: 4d33eb8888cadbccba29ac001e205db8fa717c49
2023-05-02 19:44:15 +00:00

29 lines
606 B
JavaScript

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',
},
})
export function formatTime(date, format = 'h:mm a') {
return moment(date).format(format)
}
export function relativeDate(date) {
return moment(date).calendar()
}
/**
* @param {string} isoTimestamp
* @returns {number}
*/
export function isoToUnix(isoTimestamp) {
const unixTimestamp = Date.parse(isoTimestamp) / 1000
return unixTimestamp
}