Last active
January 3, 2016 07:29
-
-
Save amosrivera/8430213 to your computer and use it in GitHub Desktop.
Returns an array of the previous 7 days.
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
| // Returns an arrary with the name of the previous seven days (?) | |
| var getPreviousWeek = function(){ | |
| // get day index monday => 0, tuesday => 1, ... | |
| var today = (new Date().getDay()-1); | |
| //0 index based array, monday => 0, tuesday => 1 and so on | |
| var days = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]; | |
| // range returns [1, 2, 3, 4, 5, 6, 7] | |
| return days.slice(today).concat(days.slice(0,today)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.npmjs.com/package/date-utils