Skip to content

Commit f069b56

Browse files
nicoschmdtpatrickelectric
authored andcommitted
frontend: use only date-fns to display time for the user
1 parent 4e353df commit f069b56

3 files changed

Lines changed: 4 additions & 14 deletions

File tree

core/frontend/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"@types/numeral": "^2.0.5",
3434
"@types/semver": "^7.3.9",
3535
"@types/semver-stable": "^3.0.0",
36-
"@types/timeago": "^1.6.0",
3736
"@types/uuid": "^9.0.0",
3837
"ansi_up": "^5.2.1",
3938
"apexcharts": "^3.36.3",
@@ -51,7 +50,6 @@
5150
"http-status-codes": "^2.2.0",
5251
"image-js": "^0.35.3",
5352
"is-ip": "^5.0.0",
54-
"javascript-time-ago": "^2.3.11",
5553
"jsoneditor": "^9.10.0",
5654
"lodash": "^4.17.21",
5755
"marked": "^4.1.1",

core/frontend/src/components/ethernet/InterfaceCard.vue

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,7 @@
177177
</template>
178178

179179
<script lang="ts">
180-
import TimeAgo from 'javascript-time-ago'
181-
import en from 'javascript-time-ago/locale/en.json'
180+
import { formatDistanceToNow } from 'date-fns'
182181
import Vue, { PropType } from 'vue'
183182
184183
import beacon from '@/store/beacon'
@@ -191,9 +190,6 @@ import AddressCreationDialog from './AddressCreationDialog.vue'
191190
import AddressDeletionDialog from './AddressDeletionDialog.vue'
192191
import DHCPServerDialog from './DHCPServerDialog.vue'
193192
194-
TimeAgo.addDefaultLocale(en)
195-
const timeAgo = new TimeAgo('en-US')
196-
197193
export default Vue.extend({
198194
name: 'InterfaceCard',
199195
components: {
@@ -375,7 +371,7 @@ export default Vue.extend({
375371
return 'Expired'
376372
}
377373
378-
return timeAgo.format(expiresAt, 'round')
374+
return formatDistanceToNow(expiresAt, { addSuffix: true })
379375
},
380376
getLeaseExpiryClass(lease: DHCPServerLease): string {
381377
const now = new Date()

core/frontend/src/components/version-chooser/VersionCard.vue

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@
132132
</template>
133133

134134
<script lang="ts">
135-
import TimeAgo from 'javascript-time-ago'
136-
import en from 'javascript-time-ago/locale/en.json'
135+
import { formatDistanceToNow } from 'date-fns'
137136
import Vue, { PropType } from 'vue'
138137
139138
import WarningDialog from '@/components/common/WarningDialog.vue'
@@ -145,9 +144,6 @@ import { DEFAULT_REMOTE_IMAGE, getFactoryVersion } from '@/utils/version_chooser
145144
146145
import SpinningLogo from '../common/SpinningLogo.vue'
147146
148-
TimeAgo.addDefaultLocale(en)
149-
const timeAgo = new TimeAgo('en-US')
150-
151147
export default Vue.extend({
152148
name: 'VersionCard',
153149
components: {
@@ -253,7 +249,7 @@ export default Vue.extend({
253249
},
254250
methods: {
255251
asTimeAgo(value: string) {
256-
return timeAgo.format(new Date(Date.parse(value)), 'round')
252+
return formatDistanceToNow(new Date(Date.parse(value)), { addSuffix: true })
257253
},
258254
shortSha(value: string) {
259255
if (value === null) {

0 commit comments

Comments
 (0)