Implement +[NSDate now]

This commit is contained in:
hmelder 2024-03-10 22:41:07 +01:00 committed by Hugo Melder
parent 648f3e2dfb
commit ca1d07dcf2
2 changed files with 13 additions and 0 deletions

View file

@ -163,6 +163,13 @@ GS_EXPORT_CLASS
*/
+ (instancetype) distantFuture;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_15, GS_API_LATEST)
/** Returns an autoreleased instance with the date/time set to
* the time of access.
*/
+ (instancetype) now;
#endif
/** Returns the time interval between the reference date and the current
* time.
*/

View file

@ -164,6 +164,12 @@ otherTime(NSDate* other)
initWithTimeIntervalSinceReferenceDate: GSPrivateTimeNow()]);
}
+ (instancetype) now
{
return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]
initWithTimeIntervalSinceReferenceDate: GSPrivateTimeNow()]);
}
/**
* Returns an autoreleased instance representing the date and time given
* by string. The value of string may be a 'natural' specification as