A class for representing and manipulating dates.
More...
#import <Foundation/Foundation.h>
|
sys_date_t | _date |
| Date and time representation.
|
|
id | _zone |
| The memory zone where the object is allocated.
|
|
unsigned short | _retain |
| The retain count of the object.
|
|
id | _next |
| The next object in an autorelease pool.
|
|
Class | isa |
| A pointer to the object's class structure. More...
|
|
A class for representing and manipulating dates.
The NXDate class provides an interface for managing dates and times. It represents a single point in time since a reference date.
- Examples:
- examples/Network/ntp/main.m.
Definition at line 22 of file NXDate.h.
◆ addTimeInterval:()
Add a time interval to this date.
- Parameters
-
interval | The time interval to add. |
◆ compare:()
Compares the date against another date, and returns the difference.
- Parameters
-
otherDate | The date to compare against. |
- Returns
- The time interval since the reference date. If the other date is later, the interval will be negative.
◆ date()
Creates and returns a new date set to the current date and time.
- Returns
- A NXDate instance representing the current date and time.
◆ dateByAddingTimeInterval:()
Return a new date by adding a time interval to this date.
- Parameters
-
interval | The time interval to add. |
- Returns
- A new NXDate instance representing the date after adding the interval.
◆ dateWithTimeIntervalSinceNow:()
Creates and returns a date object set to a given time interval from now.
- Parameters
-
interval | The interval to add to the current date. Can be positive (future) or negative (past). |
- Returns
- A NXDate instance representing the calculated date.
◆ hours:minutes:seconds:nanoseconds:()
- (BOOL) hours: |
|
(uint8_t *) |
hours |
minutes: |
|
(uint8_t *) |
minutes |
seconds: |
|
(uint8_t *) |
seconds |
nanoseconds: |
|
(uint32_t *) |
nanoseconds |
|
|
| |
Retrieves the time components from this date, in universal time.
- Parameters
-
hours | Pointer to store the hours (0-23). Can be NULL if not needed. |
minutes | Pointer to store the minutes (0-59). Can be NULL if not needed. |
seconds | Pointer to store the seconds (0-59). Can be NULL if not needed. |
nanoseconds | Pointer to store the nanoseconds (0-999999999). Can be NULL if not needed. |
- Returns
- YES if the operation was successful, NO otherwise.
- Note
- Time is returned in UTC timezone.
◆ isEarlierThan:()
Determine if the date is earlier than another date.
- Parameters
-
otherDate | The date to compare against. |
- Returns
- YES if this date is earlier than otherDate, NO otherwise.
◆ isLaterThan:()
Determine if the date is later than another date.
- Parameters
-
otherDate | The date to compare against. |
- Returns
- YES if this date is later than otherDate, NO otherwise.
◆ setHours:minutes:seconds:nanoseconds:()
- (BOOL) setHours: |
|
(uint8_t) |
hours |
minutes: |
|
(uint8_t) |
minutes |
seconds: |
|
(uint8_t) |
seconds |
nanoseconds: |
|
(uint32_t) |
nanoseconds |
|
|
| |
Sets the time components for this date object, in universal time.
- Parameters
-
hours | The hours to set (0-23). |
minutes | The minutes to set (0-59). |
seconds | The seconds to set (0-59). |
nanoseconds | The nanoseconds to set (0-999999999). |
- Returns
- YES if the time was set successfully, NO if any component is out of range.
- Note
- Time is set in UTC timezone.
-
This method preserves the date components (year, month, day) while only modifying the time portion.
◆ setYear:month:day:()
- (BOOL) setYear: |
|
(uint16_t) |
year |
month: |
|
(uint8_t) |
month |
day: |
|
(uint8_t) |
day |
|
|
| |
Sets the date components for this date object, in universal time.
- Parameters
-
year | The year to set (e.g., 2025). |
month | The month to set (1-12). |
day | The day of month to set (1-31). |
- Returns
- YES if the date was set successfully, NO if the date is invalid.
- Note
- Date is set in UTC timezone.
-
Invalid dates (e.g., February 30th) will cause this method to return NO.
◆ year:month:day:weekday:()
- (BOOL) year: |
|
(uint16_t *) |
year |
month: |
|
(uint8_t *) |
month |
day: |
|
(uint8_t *) |
day |
weekday: |
|
(uint8_t *) |
weekday |
|
|
| |
Retrieves the date components from this date, in universal time.
- Parameters
-
year | Pointer to store the year (e.g., 2025). Can be NULL if not needed. |
month | Pointer to store the month (1-12). Can be NULL if not needed. |
day | Pointer to store the day of month (1-31). Can be NULL if not needed. |
weekday | Pointer to store the day of week (0-6, Sunday=0). Can be NULL if not needed. |
- Returns
- YES if the operation was successful, NO otherwise.
The documentation for this class was generated from the following file: