forked from sproutcore/sproutcore
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a difference method to SC.DateTime
This method allow to compute the number of weeks, days, hours, minutes, or seconds between two dates.
- Loading branch information
Nicolas BADIA
authored and
Nicolas BADIA
committed
Oct 5, 2012
1 parent
066ae08
commit 2f02e5f
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
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
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
2f02e5f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1! This would have been extremely useful on a couple of projects I worked on when a total newbie.
This code would throw an error if null values are passed in. Thoughts on some gatekeeping code? Opens up a (smallish) can of worms, might not be worth it.
2f02e5f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can make this method throw an error if a or b are null, but in this case, I should also do it for the compare and compareDate methods.
Not sure to understand what you mean about gatekeeping code :(
2f02e5f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You got it - gatekeeping code is fancy words for code that quits the function early if all the ducks aren't in a row. My instinct is to return null when the arguments don't make sense (i.e. a or b is SC.none()) but I bet it would be easier for developers to debug if it threw a well-described error. Thoughts?