Created
January 4, 2019 12:59
-
-
Save asifvora/d1c4646dfdf35484a64c4bdf9668b079 to your computer and use it in GitHub Desktop.
grouped by dates
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
groupedDates(dates) { | |
let groupedDates = dates.reduce((l, r) => { | |
let date = r.OppEvents.DueDate; | |
let parseDate = new Date(Date.parse(date)); | |
let d = parseDate; | |
let dd = d.getDate(); | |
let mm = d.getMonth() + 1; //January is 0! | |
let yyyy = d.getFullYear(); | |
var key = yyyy + dd + mm; | |
if (typeof l[key] === "undefined") { | |
l[key] = []; | |
} | |
l[key].push(r); | |
return l; | |
}, {}); | |
let result = Object.keys(groupedDates).map((key) => { | |
return groupedDates[key]; | |
}); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment