Skip to content

Commit

Permalink
fix: use moment.js to convert days to milliseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
adelkahomolova committed Nov 21, 2019
1 parent fb2e323 commit 99585fe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"js-yaml": "3.13.1",
"lodash": "4.17.15",
"memfs": "2.16.1",
"moment": "^2.24.0",
"node-filter-async": "1.1.3",
"npm-check-updates": "3.2.1",
"oclif": "1.14.2",
Expand Down
5 changes: 4 additions & 1 deletion src/practices/LanguageIndependent/DoesPullRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ReporterUtils } from '../../reporters/ReporterUtils';
import { GitServiceUtils } from '../../services/git/GitServiceUtils';
import { DxPractice } from '../DxPracticeDecorator';
import { IPractice } from '../IPractice';
import moment from 'moment';

@DxPractice({
id: 'LanguageIndependent.DoesPullRequests',
Expand Down Expand Up @@ -45,7 +46,9 @@ export class DoesPullRequests implements IPractice {
const prDate = new Date(repoCommits.items[0].author.date).getTime();
const commitDate = new Date(pullRequests.items[0].createdAt).getTime();

if (prDate > commitDate - 1000 * 60 * 60 * 24 * 30) {
const daysInMilliseconds = moment.duration(30, 'days').asMilliseconds();

if (prDate > commitDate - daysInMilliseconds) {
return PracticeEvaluationResult.practicing;
}

Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5914,6 +5914,11 @@ modify-values@^1.0.0:
resolved "https://registry.yarnpkg.com/modify-values/-/modify-values-1.0.1.tgz#b3939fa605546474e3e3e3c63d64bd43b4ee6022"
integrity sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw==

moment@^2.24.0:
version "2.24.0"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b"
integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==

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

0 comments on commit 99585fe

Please sign in to comment.