Skip to content

Commit

Permalink
Replace vue-moment filter with standalone package
Browse files Browse the repository at this point in the history
Filters are removed in Vue3, so prepare by reducing filter usage.
  • Loading branch information
peace-maker committed Dec 24, 2024
1 parent 46e832d commit 0c827d0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 18 deletions.
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
"apexcharts": "^4.3.0",
"axios": "^1.7.9",
"core-js": "^3.39.0",
"moment": "^2.30.1",
"moo": "^0.5.2",
"nearley": "^2.20.1",
"pinia": "^2.3.0",
"pretty-bytes": "^6.1.1",
"tiny-typed-emitter": "^2.1.0",
"vue": "^2.7.14",
"vue-apexcharts": "git+https://github.com/apexcharts/vue-apexcharts#c4b6de32b0659a46d610e4f457afb8ede0493fef",
"vue-moment": "^4.1.0",
"vue-router": "^3.6.5",
"vuetify": "^2.6.14"
},
Expand Down
14 changes: 7 additions & 7 deletions web/src/filters.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import vue from "./main";
import moment from "moment";

export function capitalize(value: string | null) {
if (!value) return "";
Expand All @@ -13,21 +13,21 @@ export function tagify(id: string, what: "id" | "type" | "name") {
}

export function formatDuration(seconds: number) {
return vue.$moment.duration(seconds, "seconds").humanize();
return moment.duration(seconds, "seconds").humanize();
}

export function formatDate(time: string | Date | null) {
if (time === null) return undefined;
const moment = vue.$moment(time).local();
const date = moment(time).local();
let format = "HH:mm:ss.SSS";
if (!moment.isSame(vue.$moment(), "day")) format = `YYYY-MM-DD ${format}`;
return moment.format(format);
if (!date.isSame(moment(), "day")) format = `YYYY-MM-DD ${format}`;
return date.format(format);
}

export function formatDateLong(time: string | Date | null) {
if (time === null) return undefined;
const moment = vue.$moment(time).local();
return moment.format("YYYY-MM-DD HH:mm:ss.SSS ZZ");
const date = moment(time).local();
return date.format("YYYY-MM-DD HH:mm:ss.SSS ZZ");
}

export function tagForURI(tagId: string) {
Expand Down
2 changes: 0 additions & 2 deletions web/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import { createPinia, PiniaVuePlugin } from "pinia";
import App from "./App.vue";
import router from "./routes";
import VueApexCharts from "vue-apexcharts";
import * as VueMoment from "vue-moment";

Vue.config.productionTip = process.env.NODE_ENV == "production";

Vue.use(PiniaVuePlugin);
Vue.use(Vuetify);
Vue.use(VueApexCharts);
Vue.use(VueMoment);

Vue.component("Apexchart", VueApexCharts);

Expand Down
9 changes: 1 addition & 8 deletions web/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2095,7 +2095,7 @@ mlly@^1.7.2, mlly@^1.7.3:
pkg-types "^1.2.1"
ufo "^1.5.4"

moment@>=2.24.0, moment@^2.19.2:
moment@>=2.24.0, moment@^2.30.1:
version "2.30.1"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.30.1.tgz#f8c91c07b7a786e30c59926df530b4eac96974ae"
integrity sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==
Expand Down Expand Up @@ -3059,13 +3059,6 @@ vue-eslint-parser@^9.3.1, vue-eslint-parser@^9.4.3:
lodash "^4.17.21"
semver "^7.3.6"

vue-moment@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/vue-moment/-/vue-moment-4.1.0.tgz#092a8ff723a96c6f85a0a8e23ad30f0bf320f3b0"
integrity sha512-Gzisqpg82ItlrUyiD9d0Kfru+JorW2o4mQOH06lEDZNgxci0tv/fua1Hl0bo4DozDV2JK1r52Atn/8QVCu8qQw==
dependencies:
moment "^2.19.2"

vue-router@^3.6.5:
version "3.6.5"
resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-3.6.5.tgz#95847d52b9a7e3f1361cb605c8e6441f202afad8"
Expand Down

0 comments on commit 0c827d0

Please sign in to comment.