From bc4deb887b45e523152c64bfe00c727c8989004f Mon Sep 17 00:00:00 2001 From: Howard Edwards Date: Wed, 11 Jan 2023 17:20:41 -0500 Subject: [PATCH] Shift date management from momentjs to dayjs --- client/package.json | 2 +- client/utils/formatter.js | 10 +++++----- server/package.json | 2 +- server/resolvers/TestPlanReport/issuesResolver.js | 4 ++-- yarn.lock | 7 ++++++- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/client/package.json b/client/package.json index 6888deb15..0bc3c3014 100644 --- a/client/package.json +++ b/client/package.json @@ -33,9 +33,9 @@ "@react-hook/resize-observer": "^1.2.6", "bootstrap": "^5.2.3", "core-js": "^3.8.0", + "dayjs": "^1.11.7", "graphql": "^16.6.0", "lodash": "^4.17.21", - "moment": "^2.25.3", "node-fetch": "^2.6.1", "object-hash": "^3.0.0", "octicons-react": "^1.0.4", diff --git a/client/utils/formatter.js b/client/utils/formatter.js index e53d59fd8..9a607c108 100644 --- a/client/utils/formatter.js +++ b/client/utils/formatter.js @@ -1,4 +1,4 @@ -import moment from 'moment'; +import dayjs from 'dayjs'; /** * Transforms the provided string by capitalizing the first letter of each word. @@ -24,11 +24,11 @@ export const capitalizeEachWord = ( export const convertDateToString = (date, format = 'DD-MM-YYYY') => { if (!date) return ''; - return moment(date).format(format); + return dayjs(date).format(format); }; export const convertStringToDate = (date, format = 'DD-MM-YYYY') => { - return moment(date, format).toDate(); + return dayjs(date, format).toDate(); }; export const convertStringFormatToAnotherFormat = ( @@ -36,9 +36,9 @@ export const convertStringFormatToAnotherFormat = ( fromFormat = 'DD-MM-YYYY', toFormat = 'MM-DD-YYYY' ) => { - return moment(date, fromFormat).format(toFormat); + return dayjs(date, fromFormat).format(toFormat); }; export const isValidDate = (date, format = 'DD-MM-YYYY') => { - return moment(date, format).isValid(); + return dayjs(date, format).isValid(); }; diff --git a/server/package.json b/server/package.json index eaa089587..05bd07ef7 100644 --- a/server/package.json +++ b/server/package.json @@ -35,6 +35,7 @@ "connect-pg-simple": "^8.0.0", "cross-fetch": "^3.1.5", "cross-spawn": "^7.0.3", + "dayjs": "^1.11.7", "dotenv": "^16.0.3", "dotenv-cli": "^6.0.0", "express": "^5.0.0-alpha.8", @@ -45,7 +46,6 @@ "js-base64": "^3.6.1", "lodash": "^4.17.21", "minimist": "^1.2.7", - "moment": "^2.29.4", "node-cache": "^5.1.2", "nodegit": "^0.28.0-alpha.20", "nodemon": "^2.0.7", diff --git a/server/resolvers/TestPlanReport/issuesResolver.js b/server/resolvers/TestPlanReport/issuesResolver.js index b097c911d..8b72e1ca0 100644 --- a/server/resolvers/TestPlanReport/issuesResolver.js +++ b/server/resolvers/TestPlanReport/issuesResolver.js @@ -1,6 +1,6 @@ const { GithubService } = require('../../services'); const { Base64 } = require('js-base64'); -const moment = require('moment'); +const dayjs = require('dayjs'); const issuesResolver = async testPlanReport => { if (!testPlanReport.candidateStatusReachedAt) return []; @@ -8,7 +8,7 @@ const issuesResolver = async testPlanReport => { const searchPrefix = `${testPlanReport.at.name} Feedback: "`; const searchTestPlanVersionTitle = testPlanReport.testPlanVersion.dataValues.title; - const searchTestPlanVersionDate = moment( + const searchTestPlanVersionDate = dayjs( testPlanReport.testPlanVersion.updatedAt ).format('DD-MM-YYYY'); const cacheId = Base64.encode( diff --git a/yarn.lock b/yarn.lock index f3d188ca6..d89b3c6b0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6149,6 +6149,11 @@ data-urls@^3.0.2: whatwg-mimetype "^3.0.0" whatwg-url "^11.0.0" +dayjs@^1.11.7: + version "1.11.7" + resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.7.tgz#4b296922642f70999544d1144a2c25730fce63e2" + integrity sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ== + debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.8, debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" @@ -10903,7 +10908,7 @@ moment-timezone@^0.5.21: dependencies: moment ">= 2.9.0" -"moment@>= 2.9.0", moment@^2.24.0, moment@^2.25.3, moment@^2.29.4: +"moment@>= 2.9.0", moment@^2.24.0: version "2.29.4" resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108" integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==