Skip to content

Commit

Permalink
Merge branch 'master' into fix/casestudy
Browse files Browse the repository at this point in the history
  • Loading branch information
anshgoyalevil authored Mar 5, 2024
2 parents 3342edc + de480f2 commit 593d120
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cypress/test/scripts/dashboard/build-dashboard.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ describe('getLabel function', () => {
describe('monthsSince function', () => {
// Define some sample dates and expected results
const today = new Date();
const oneMonthAgo = new Date(today.getFullYear(), today.getMonth() - 1, today.getDate());
const twoMonthsAgo = new Date(today.getFullYear(), today.getMonth() - 2, today.getDate());
const threeMonthsAgo = new Date(today.getFullYear(), today.getMonth() - 3, today.getDate());

// number of miliseconds in a month
const month = 30 * 24 * 60 * 60 * 1000;

const oneMonthAgo = today - month;
const twoMonthsAgo = today - 2 * month;
const threeMonthsAgo = today - 3 * month;

// Write the test cases
it('should return 0 for the same date', () => {
Expand Down
1 change: 1 addition & 0 deletions scripts/dashboard/build-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function getLabel(issue, filter) {

function monthsSince(date) {
const seconds = Math.floor((new Date() - new Date(date)) / 1000);
// 2592000 = number of seconds in a month = 30 * 24 * 60 * 60
const months = seconds / 2592000;
return Math.floor(months);
}
Expand Down

0 comments on commit 593d120

Please sign in to comment.