Created
May 21, 2014 08:14
-
-
Save uudashr/b8f0a868b75cafcdd0c6 to your computer and use it in GitHub Desktop.
Get the bounds of a day
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
function dayBounds(date) { | |
var t1 = new Date(date.getTime()); | |
t1.setHours(0, 0, 0, 0); | |
var t2 = new Date(date.getTime()); | |
t2.setHours(23, 59, 59, 999); | |
return [t1, t2]; | |
} | |
Date.prototype.dayBounds = function() { | |
return dayBounds(this); | |
}; |
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
function sameDay(date1, date2) { | |
return date1.getFullYear() == date2.getFullYear() && | |
date1.getMonth() == date2.getMonth() && | |
date1.getDate() == date2.getDate(); | |
} | |
Date.prototype.sameDay = function(otherDate) { | |
return sameDay(this, otherDate); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment