Skip to content

Commit

Permalink
Shift date management from momentjs to dayjs
Browse files Browse the repository at this point in the history
  • Loading branch information
howard-e committed Feb 13, 2023
1 parent 72a14b1 commit 817bcdb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions client/utils/formatter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import moment from 'moment';
import dayjs from 'dayjs';

/**
* Transforms the provided string by capitalizing the first letter of each word.
Expand All @@ -24,21 +24,21 @@ 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 = (
date,
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();
};
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions server/resolvers/TestPlanReport/issuesResolver.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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 [];

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(
Expand Down
7 changes: 6 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==

[email protected], 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"
Expand Down Expand Up @@ -10908,7 +10913,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==
Expand Down

0 comments on commit 817bcdb

Please sign in to comment.