Created
January 18, 2013 21:19
-
-
Save ecowden/4568631 to your computer and use it in GitHub Desktop.
User the SugarJS date functions to find Mondays
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
/* | |
* SugarJS is a super handy tool for common JavaScript functions. | |
* | |
* Recently, we needed to find Mondays. This Monday, next Monday, three Mondays ago...Mondays | |
* for everyone! SugarJS made this kind of logic dead simple. Here is one way to | |
* tackle the problem. | |
*/ | |
var thisMonday = Date.create().beginningOfWeek().addDays(1); | |
var eightMondaysAgo = Date.create().rewind({days: 7 * 8}).beginningOfWeek().addDays(1); | |
var threeMondaysFromNow = Date.create().advance({days: 7 * 3}).beginningOfWeek().addDays(1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment