diff --git a/package.json b/package.json index e1f69e8e..e9e682e2 100644 --- a/package.json +++ b/package.json @@ -11,14 +11,14 @@ "dependencies": { "axios": "^0.21.1", "core-js": "^3.9.0", + "dayjs": "^1.10.4", "highlight.js": "^10.6.0", - "moment": "^2.24.0", "serialize-javascript": "^3.1.0", "vue": "^2.6.10", "vue-codemirror": "^4.0.6", + "vue-dayjs": "^1.0.2", "vue-highlightjs": "^1.3.3", "vue-marquee-text-component": "^1.1.1", - "vue-moment": "^4.1.0", "vue-router": "^3.5.1", "vue-the-mask": "^0.11.1", "vuetify": "^2.4.4", diff --git a/src/main.js b/src/main.js index 8c1f1364..d2ba818e 100644 --- a/src/main.js +++ b/src/main.js @@ -7,7 +7,7 @@ import App from "./App.vue"; import vuetify from "./plugins/vuetify"; import router from "./plugins/router"; -import "./plugins/moment"; +import "./plugins/dayjs"; import "./plugins/codemirror"; import "./plugins/highlightjs"; diff --git a/src/plugins/dayjs.js b/src/plugins/dayjs.js new file mode 100644 index 00000000..9270dd57 --- /dev/null +++ b/src/plugins/dayjs.js @@ -0,0 +1,4 @@ +import Vue from "vue"; +import dayjs from "vue-dayjs"; + +Vue.use(dayjs); diff --git a/src/plugins/moment.js b/src/plugins/moment.js deleted file mode 100644 index fea20951..00000000 --- a/src/plugins/moment.js +++ /dev/null @@ -1,4 +0,0 @@ -import Vue from "vue"; -import moment from "vue-moment"; - -Vue.use(moment); diff --git a/src/store/quiz.js b/src/store/quiz.js index 64490ab9..8bae6631 100644 --- a/src/store/quiz.js +++ b/src/store/quiz.js @@ -1,9 +1,11 @@ import { mapState } from "vuex"; import { quiz } from "@/api"; -import moment from "moment"; +import dayjs from "dayjs"; import Vue from "vue"; +import updateLocale from "dayjs/plugin/updateLocale"; -moment.updateLocale("en", { +dayjs.extend(updateLocale); +dayjs.updateLocale("en", { relativeTime: { future: "in %s", past: "%s ago", @@ -44,7 +46,7 @@ function parseDateResponse(dateResponse) { const hours = time[0]; const minutes = time[1]; const seconds = time[2]; - return moment() + return dayjs() .add(days, "days") .add(hours, "hours") .add(minutes, "minutes") @@ -54,8 +56,8 @@ function parseDateResponse(dateResponse) { function getDefaultState() { return { hasSeenIntro: false, - nextUnlockMoment: moment(), - quizStartedMoment: moment(), + nextUnlockMoment: dayjs(), + quizStartedMoment: dayjs(), question: "", asset: "", rank: 0, @@ -97,7 +99,7 @@ const actions = { commit("maxRank", rank.maxRank); commit( "quizStartedMoment", - moment(rank.startsOn + "+0000", "MM/DD/YYYY HH:mm Z") + dayjs(rank.startsOn + "+0000", "MM/DD/YYYY HH:mm Z") ); if (rank.rank < 0) { commit("quizHasStarted", false); @@ -127,7 +129,7 @@ const actions = { commit("asset", response.asset); commit("rank", response.rank); commit("hints", response.hints); - commit("nextUnlockMoment", moment()); + commit("nextUnlockMoment", dayjs()); commit("isLastQuestion", response.rank === state.maxRank); } catch (err) { if (err.status === 404) { diff --git a/yarn.lock b/yarn.lock index 49651e57..59b178af 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3072,6 +3072,11 @@ dashdash@^1.12.0: dependencies: assert-plus "^1.0.0" +dayjs@^1.10.4, dayjs@^1.5.24: + version "1.10.4" + resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.10.4.tgz#8e544a9b8683f61783f570980a8a80eaf54ab1e2" + integrity sha512-RI/Hh4kqRc1UKLOAf/T5zdMMX5DQIlDxwUe3wSyMMnEbGunnpENCdbUgM+dW7kXidZqCttBrmw7BhN4TMddkCw== + de-indent@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d" @@ -5798,11 +5803,6 @@ mixin-deep@^1.2.0: dependencies: minimist "^1.2.5" -moment@^2.19.2, moment@^2.24.0: - version "2.29.1" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.1.tgz#b2be769fa31940be9eeea6469c075e35006fa3d3" - integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ== - move-concurrently@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92" @@ -8732,6 +8732,13 @@ vue-codemirror@^4.0.6: codemirror "^5.41.0" diff-match-patch "^1.0.0" +vue-dayjs@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/vue-dayjs/-/vue-dayjs-1.0.2.tgz#0fb3fc072d0ec8edf0f2bc0ba51a0b3a03a8dc45" + integrity sha512-rYvbpjZ6ZZ2MyQPpyltQmPBqd4+2RRfcFZb5/Fa6VsmBCmeSXTl6RHrHSOY72y5NJOrrxTpBg6VnP556gNSU7w== + dependencies: + dayjs "^1.5.24" + vue-eslint-parser@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-5.0.0.tgz#00f4e4da94ec974b821a26ff0ed0f7a78402b8a1" @@ -8784,13 +8791,6 @@ vue-marquee-text-component@^1.1.1: core-js "^3.6.5" vue "^2.5.17" -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.5.1: version "3.5.1" resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-3.5.1.tgz#edf3cf4907952d1e0583e079237220c5ff6eb6c9"