Replaced moment with dayjs
This commit is contained in:
parent
7e1ec9f3ae
commit
f462717bb3
@ -48,7 +48,6 @@
|
||||
"keycloak-js": "^26.2.0",
|
||||
"keytar": "^7.9.0",
|
||||
"loglevel": "^1.9.2",
|
||||
"moment": "^2.30.1",
|
||||
"online-3d-viewer": "^0.16.0",
|
||||
"prettier": "^3.6.2",
|
||||
"prettier-eslint": "^16.4.2",
|
||||
@ -113,6 +112,7 @@
|
||||
"express": "^5.1.0",
|
||||
"prettier": "^3.6.2",
|
||||
"prettier-eslint": "^16.4.2",
|
||||
"rollup-plugin-visualizer": "^6.0.5",
|
||||
"serve": "^14.2.4",
|
||||
"standard": "^17.1.2",
|
||||
"svgo": "^4.0.0",
|
||||
|
||||
@ -2,22 +2,48 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Flex, Typography, Tag } from 'antd'
|
||||
import moment from 'moment'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
const { Text } = Typography
|
||||
|
||||
const formatTimeDifference = (dateTime) => {
|
||||
const now = moment()
|
||||
const diff = moment(dateTime)
|
||||
const duration = moment.duration(now.diff(diff))
|
||||
const now = dayjs()
|
||||
const diff = dayjs(dateTime)
|
||||
|
||||
const years = Math.floor(duration.asYears())
|
||||
const months = Math.floor(duration.asMonths()) % 12
|
||||
const weeks = Math.floor(duration.asWeeks()) % 4
|
||||
const days = Math.floor(duration.asDays()) % 7
|
||||
const hours = duration.hours()
|
||||
const minutes = duration.minutes()
|
||||
const seconds = duration.seconds()
|
||||
const years = now.diff(diff, 'year')
|
||||
const months = now.diff(diff.add(years, 'year'), 'month')
|
||||
const weeks = now.diff(diff.add(years, 'year').add(months, 'month'), 'week')
|
||||
const days = now.diff(
|
||||
diff.add(years, 'year').add(months, 'month').add(weeks, 'week'),
|
||||
'day'
|
||||
)
|
||||
const hours = now.diff(
|
||||
diff
|
||||
.add(years, 'year')
|
||||
.add(months, 'month')
|
||||
.add(weeks, 'week')
|
||||
.add(days, 'day'),
|
||||
'hour'
|
||||
)
|
||||
const minutes = now.diff(
|
||||
diff
|
||||
.add(years, 'year')
|
||||
.add(months, 'month')
|
||||
.add(weeks, 'week')
|
||||
.add(days, 'day')
|
||||
.add(hours, 'hour'),
|
||||
'minute'
|
||||
)
|
||||
const seconds = now.diff(
|
||||
diff
|
||||
.add(years, 'year')
|
||||
.add(months, 'month')
|
||||
.add(weeks, 'week')
|
||||
.add(days, 'day')
|
||||
.add(hours, 'hour')
|
||||
.add(minutes, 'minute'),
|
||||
'second'
|
||||
)
|
||||
|
||||
if (years > 0) {
|
||||
return `${years}y`
|
||||
@ -67,7 +93,7 @@ const TimeDisplay = ({
|
||||
dateFormat += 'HH:mm:ss '
|
||||
}
|
||||
|
||||
const formattedDate = moment(dateTime).format(dateFormat)
|
||||
const formattedDate = dayjs(dateTime).format(dateFormat)
|
||||
|
||||
return (
|
||||
<Flex align={'center'} gap={'small'}>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user