Created
July 19, 2010 11:17
-
-
Save klaaspieter/481288 to your computer and use it in GitHub Desktop.
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
[[CPDate dateWithTimeIntervalSince1970:seconds] isEqualToDate:[CPDate dateWithTimeIntervalSince1970:seconds]] | |
// initWithTimeIntervalSince1970 is defined as | |
- (id)initWithTimeIntervalSince1970:(CPTimeInterval)seconds | |
{ | |
self = new Date(seconds * 1000); | |
return self; | |
} | |
// equalToDate was defined as (not working) | |
- (BOOL)isEqualToDate:(CPDate)aDate | |
{ | |
if (!aDate) | |
return NO; | |
return self === aDate; | |
} | |
// equalToDate is now defined as (working) | |
- (BOOL)isEqualToDate:(CPDate)aDate | |
{ | |
if (!aDate) | |
return NO; | |
return !(self < aDate || self > aDate); | |
} |
I'm not wondering about browser implementation, more about if they will always return the same value for the same time. I've read several comments on Stackoverflow which said they were unsure about it.
If it's guaranteed to always be equal than the question is which of these two methods is faster. :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why would you wonder that? Afaik, the valueOf method is implemented by all, as it is the way to get a primitive value out of objects. For instance: http://msdn.microsoft.com/en-us/library/ftx8swz5(v=VS.85).aspx, https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Object/valueOf etc.