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