refactor(deps): Replace moment with dayjs (#8192)
This commit is contained in:
@@ -2,8 +2,11 @@
|
||||
* Commonly-used functions for formatting text in badge labels. Includes
|
||||
* ordinal numbers, currency codes, star ratings, versions, etc.
|
||||
*/
|
||||
import moment from 'moment'
|
||||
moment().format()
|
||||
import dayjs from 'dayjs'
|
||||
import calendar from 'dayjs/plugin/calendar.js'
|
||||
import relativeTime from 'dayjs/plugin/relativeTime.js'
|
||||
dayjs.extend(calendar)
|
||||
dayjs.extend(relativeTime)
|
||||
|
||||
function starRating(rating, max = 5) {
|
||||
const flooredRating = Math.floor(rating)
|
||||
@@ -109,7 +112,7 @@ function maybePluralize(singular, countable, plural) {
|
||||
}
|
||||
|
||||
function formatDate(d) {
|
||||
const date = moment(d)
|
||||
const date = dayjs(d)
|
||||
const dateString = date.calendar(null, {
|
||||
lastDay: '[yesterday]',
|
||||
sameDay: '[today]',
|
||||
@@ -117,12 +120,12 @@ function formatDate(d) {
|
||||
sameElse: 'MMMM YYYY',
|
||||
})
|
||||
// Trim current year from date string
|
||||
return dateString.replace(` ${moment().year()}`, '').toLowerCase()
|
||||
return dateString.replace(` ${dayjs().year()}`, '').toLowerCase()
|
||||
}
|
||||
|
||||
function formatRelativeDate(timestamp) {
|
||||
return moment()
|
||||
.to(moment.unix(parseInt(timestamp, 10)))
|
||||
return dayjs()
|
||||
.to(dayjs.unix(parseInt(timestamp, 10)))
|
||||
.toLowerCase()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user