This method allow to compute the number of weeks, days, hours, minutes,
or seconds between two dates.
Add a difference method to SC.DateTime
+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.
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 :(
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?
Throw errors is the passed parameters are invalid
As suggest by dcporter an error is now throw for the methods: compare,
compareDate and difference if the parameters are incorrect.
The result should be rounded
Rebased directly onto master. Thanks!