Created
December 29, 2011 14:41
-
-
Save mdarby/1534381 to your computer and use it in GitHub Desktop.
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
someFunction: (date) -> | |
startOfMonth = date.beginningOfMonth() | |
endOfMonth = date.endOfMonth() | |
console.log startOfMonth.format('{MM}-{DD}-{YYYY}') | |
console.log endOfMonth.format('{MM}-{DD}-{YYYY}') | |
console.log '---' | |
# I call someFunction() with the SugarJS Date objects representing "12-09-2011" and "01-09-2012" and get this in the console: | |
# 12-31-2011 | |
# 12-31-2011 | |
# --- | |
# 01-31-2012 | |
# 01-31-2012 | |
# --- | |
# Why is `endOfMonth` clobbering `startOfMonth`? | |
# To get around this, I had to do: | |
startOfMonth = Date.create(date.format('{MM}-{DD}-{YYYY}')).beginningOfMonth() | |
endOfMonth = Date.create(date.format('{MM}-{DD}-{YYYY}')).endOfMonth() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maybe it is because you are calling it on the date object, and Sugar could be overwriting it?