A date and time, to the nanosecond, with the offset of a time zone. More...
#import <Foundation/Foundation.h>


Instance Methods | |
| (id) | - init |
| Initializes the current date. | |
| (id) | - initWithSeconds:nanoseconds: |
| Initializes a date from the number of seconds since 1970-01-01 in UTC. | |
| (id) | - initWithYear:month:day:hours:minutes:seconds: |
| Initializes a date and time in UTC. | |
| (id) | - initWithString:format: |
| Initializes a date read from a string in a format. | |
| (int64_t) | - seconds |
| Returns the number of whole seconds since 1970-01-01 in UTC, which is negative before then. | |
| (int32_t) | - nanoseconds |
| Returns the nanoseconds after the seconds, from zero to 999999999. | |
| (int32_t) | - timeZoneOffset |
| Returns the offset of the time zone, in seconds east of UTC. | |
| (NXDate *) | - dateWithTimeZoneOffset: |
| Returns the same moment in another time zone. More... | |
| (NXDate *) | - dateByAddingDuration: |
| Returns this date with a duration added, which is earlier if it's negative. More... | |
| (NXDuration) | - durationSinceDate: |
| Returns the time since another date, which is negative if that's later. More... | |
| (NXComparisonResult) | - compare: |
| Compares the moments of two dates. More... | |
| (BOOL) | - isEqual: |
| Returns YES if another object is a date at the same moment. | |
| (uintptr_t) | - hash |
| Returns a hash of the moment, which is the same for equal dates, whatever their time zones. | |
| (BOOL) | - year:month:day:weekday: |
| Gets the date in UTC. More... | |
| (BOOL) | - hours:minutes:seconds: |
| Gets the time in UTC. More... | |
| (BOOL) | - localYear:month:day:weekday: |
| Gets the date in the date's time zone. More... | |
| (BOOL) | - localHours:minutes:seconds: |
| Gets the time in the date's time zone. More... | |
| (NXString *) | - stringWithFormat: |
| Returns the date written in a format, or nil if the year isn't from 0 to 65535 or there isn't enough memory. | |
| (NXString *) | - description |
| Returns the date in ISO 8601, such as "2026-09-06T11:37:05Z", or nil if the year isn't from 0 to 65535. | |
Instance Methods inherited from NXObject | |
| (void) | - dealloc |
| Frees the instance. More... | |
| (NXZone *) | - zone |
| Returns the zone in which the instance was allocated. More... | |
| (id) | - retain |
| Increases the retain count of the receiver. More... | |
| (void) | - release |
| Decreases the retain count of the receiver. More... | |
| (id) | - autorelease |
| Releases the receiver later, when the current autorelease pool of the thread is drained. More... | |
| (id) | - copy |
| Returns a copy which can't be changed by anything else, which the caller owns and has to release. More... | |
Instance Methods inherited from Object | |
| (Class) | - class |
| Returns the class of the instance. More... | |
| (Class) | - superclass |
| Returns the superclass of the instance. More... | |
| (BOOL) | - isKindOfClass: |
| Returns a Boolean value that indicates whether the receiver is an instance of a given class. More... | |
| (BOOL) | - conformsTo: |
| Checks if the receiver's class conforms to a protocol. More... | |
Instance Methods inherited from <ObjectProtocol> | |
| (BOOL) | - respondsToSelector: |
| Checks if the receiver responds to a selector. More... | |
Class Methods | |
| (id) | + date |
| Returns the current date, or nil if the clock can't be read. | |
| (id) | + dateWithDuration: |
| Returns the current date with a duration added, which is earlier if it's negative. | |
| (id) | + dateWithSeconds:nanoseconds: |
| Returns a date from the number of seconds since 1970-01-01 in UTC. More... | |
| (id) | + dateWithYear:month:day: |
| Returns a date at midnight in UTC, or nil if it doesn't exist. More... | |
| (id) | + dateWithYear:month:day:hours:minutes:seconds: |
| Returns a date and time in UTC, or nil if it doesn't exist. More... | |
| (id) | + dateWithString:format: |
| Returns a date read from a string in a format. More... | |
| (id) | + dateWithString: |
| Returns a date read from a string in any of the formats, which are tried in turn, or nil if it isn't one. | |
| (BOOL) | + setCurrentDate: |
| Sets the clock of the system. More... | |
Class Methods inherited from NXObject | |
| (id) | + alloc |
| Allocates a new instance in the default zone, or if there isn't one, with sys_calloc(). More... | |
| (id) | + allocWithZone: |
| Allocates a new instance in a specific zone. More... | |
| (id) | + new |
| Allocates and initializes a new instance, as [[cls alloc] init] does. More... | |
Class Methods inherited from Object | |
| (void) | + initialize |
| Performs one-time initialization for the class. More... | |
| (Class) | + class |
| Returns the class object. More... | |
| (Class) | + superclass |
| Returns the superclass of the class. More... | |
| (const char *) | + name |
| Returns the name of the class. More... | |
| (BOOL) | + conformsTo: |
| Checks if the class conforms to a protocol. More... | |
Additional Inherited Members | |
Protected Attributes inherited from Object | |
| Class | isa |
| A pointer to the object's class structure. More... | |
A date and time, to the nanosecond, with the offset of a time zone.
A date is a sys_date_t of picofuse, and can't be changed once it's made. Its parts, and how it's written, are only available for the years 0 to 65535.
The time zone only changes how a date is written, and its local parts: two dates at the same moment are equal, whatever their time zones. The current date has the time zone of the system; others are in UTC unless they're given one.
On a Pico, the clock starts at 1970-01-01 when it's turned on, until it's set, and is to the millisecond.
A date can't change, so any number of threads can use it at once. See Threads and mutable objects.
| - (NXComparisonResult) compare: | (NXDate *) | other |
Compares the moments of two dates.
If the other is nil, it's the current date.
| - (NXDate *) dateByAddingDuration: | (NXDuration) | duration |
Returns this date with a duration added, which is earlier if it's negative.
| + (id) dateWithSeconds: | (int64_t) | seconds | |
| nanoseconds: | (int32_t) | nanoseconds | |
Returns a date from the number of seconds since 1970-01-01 in UTC.
| seconds | The seconds, which are negative before 1970. |
| nanoseconds | The nanoseconds after that. Any more than a second, or fewer than zero, are carried into the seconds. |
| + (id) dateWithString: | (NXString *) | string | |
| format: | (NXDateFormat) | format | |
Returns a date read from a string in a format.
| string | The whole of it is a date in the format:
|
| format | The format. |
| - (NXDate *) dateWithTimeZoneOffset: | (int32_t) | offset |
Returns the same moment in another time zone.
| offset | The offset, in seconds east of UTC. It's written in ISO 8601 to the minute. |
| + (id) dateWithYear: | (uint16_t) | year | |
| month: | (uint8_t) | month | |
| day: | (uint8_t) | day | |
Returns a date at midnight in UTC, or nil if it doesn't exist.
| year | The year, from 1900 to 65535. |
| month | The month, from 1 to 12. |
| day | The day of the month, from 1. |
| + (id) dateWithYear: | (uint16_t) | year | |
| month: | (uint8_t) | month | |
| day: | (uint8_t) | day | |
| hours: | (uint8_t) | hours | |
| minutes: | (uint8_t) | minutes | |
| seconds: | (uint8_t) | seconds | |
Returns a date and time in UTC, or nil if it doesn't exist.
| year | The year, from 1900 to 65535. |
| month | The month, from 1 to 12. |
| day | The day of the month, from 1. |
| hours | From 0 to 23. |
| minutes | From 0 to 59. |
| seconds | From 0 to 59. |
| - (NXDuration) durationSinceDate: | (NXDate *) | other |
Returns the time since another date, which is negative if that's later.
| other | The other date, or nil for the current date. |
| - (BOOL) hours: | (uint8_t *) | hours | |
| minutes: | (uint8_t *) | minutes | |
| seconds: | (uint8_t *) | seconds | |
Gets the time in UTC.
Any of the arguments can be NULL.
| - (BOOL) localHours: | (uint8_t *) | hours | |
| minutes: | (uint8_t *) | minutes | |
| seconds: | (uint8_t *) | seconds | |
Gets the time in the date's time zone.
Any of the arguments can be NULL.
| - (BOOL) localYear: | (uint16_t *) | year | |
| month: | (uint8_t *) | month | |
| day: | (uint8_t *) | day | |
| weekday: | (uint8_t *) | weekday | |
Gets the date in the date's time zone.
Any of the arguments can be NULL.
Sets the clock of the system.
On a Pico, the time zone of the date becomes that of the system.
| - (BOOL) year: | (uint16_t *) | year | |
| month: | (uint8_t *) | month | |
| day: | (uint8_t *) | day | |
| weekday: | (uint8_t *) | weekday | |
Gets the date in UTC.
Any of the arguments can be NULL.
| year | The year. |
| month | The month, from 1 to 12. |
| day | The day of the month, from 1. |
| weekday | The day of the week, from 0 for Sunday to 6. |