Last active
August 29, 2015 14:23
-
-
Save clintonhalpin/56c169522700f349ad9a to your computer and use it in GitHub Desktop.
Get starting Week
This file contains hidden or 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
| function getStartingSunday(date) { | |
| var dayToGet = moment(date) | |
| return dayToGet.subtract(1, 'weeks').endOf('isoWeek') | |
| } | |
| function _buildWeek(date) { | |
| var days = []; | |
| for (var i = 0; i < 7; i++) { | |
| days.push({ | |
| name: date.format("dd"), | |
| number: date.date(), | |
| isToday: date.isSame(new Date(), "day"), | |
| date: date | |
| }); | |
| date = date.clone(); | |
| date.add(1, "d"); | |
| } | |
| return days; | |
| } | |
| var days = _buildWeek(getStartingSunday(moment())); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment