-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update isNewMap helper to automate end of year summary tagging
- Loading branch information
Showing
2 changed files
with
20 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
// returns true when a date is within the past 2 months | ||
// except in the month of december, which returns true | ||
// if the date is within the same year | ||
// | ||
// used to give maps a 'new' tag and highlight | ||
|
||
module.exports = function(created) { | ||
var threshold = new Date(); | ||
threshold = threshold.setMonth(threshold.getMonth() - 2); // 2 months ago | ||
const today = new Date(); | ||
var threshold = new Date().setMonth(today.getMonth() - 2); | ||
if (today.getMonth() === 11) { | ||
threshold = new Date(`${today.getFullYear()}-01-01`); | ||
}; | ||
|
||
// return Date.parse(created) > threshold; | ||
return Date.parse(created) > new Date('2023-01-01'); | ||
return Date.parse(created) > threshold; | ||
}; |