Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

replace moment and vue-moment with dayjs and vue-dayjs #222

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
4 changes: 4 additions & 0 deletions src/plugins/dayjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Vue from "vue";
import dayjs from "vue-dayjs";

Vue.use(dayjs);
4 changes: 0 additions & 4 deletions src/plugins/moment.js

This file was deleted.

16 changes: 9 additions & 7 deletions src/store/quiz.js
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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")
Expand All @@ -54,8 +56,8 @@ function parseDateResponse(dateResponse) {
function getDefaultState() {
return {
hasSeenIntro: false,
nextUnlockMoment: moment(),
quizStartedMoment: moment(),
nextUnlockMoment: dayjs(),
quizStartedMoment: dayjs(),
question: "",
asset: "",
rank: 0,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
24 changes: 12 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down