mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-05 03:33:41 -05:00
788ebd2bce
* added lastUpdatedTimestamp in label list item * formatTimeBasedOnYear * removed unused translation * fix typos * translate last_edit * use moment().subtract() * using moment.diff * fix formatting GitOrigin-RevId: 16af3962eaa4c718fcd749caaff05de82a431bcc
37 lines
819 B
JavaScript
37 lines
819 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()
|
|
}
|
|
|
|
export function formatTimeBasedOnYear(date) {
|
|
const currentDate = moment()
|
|
|
|
return currentDate.diff(date, 'years') > 0
|
|
? formatTime(date, 'D MMMM YYYY, h:mm a')
|
|
: formatTime(date, 'D MMMM, h:mm a')
|
|
}
|
|
|
|
/**
|
|
* @param {string} isoTimestamp
|
|
* @returns {number}
|
|
*/
|
|
export function isoToUnix(isoTimestamp) {
|
|
const unixTimestamp = Date.parse(isoTimestamp) / 1000
|
|
return unixTimestamp
|
|
}
|