objc

Instance Methods | Class Methods | Protected Attributes
NXDate Class Reference

A class for representing and manipulating dates. More...

#import <Foundation/Foundation.h>

Inheritance diagram for NXDate:
Inheritance graph
[legend]
Collaboration diagram for NXDate:
Collaboration graph
[legend]

Instance Methods

(BOOL- year:month:day:weekday:
 Retrieves the date components from this date, in universal time. More...
 
(BOOL- hours:minutes:seconds:nanoseconds:
 Retrieves the time components from this date, in universal time. More...
 
(BOOL- setYear:month:day:
 Sets the date components for this date object, in universal time. More...
 
(BOOL- setHours:minutes:seconds:nanoseconds:
 Sets the time components for this date object, in universal time. More...
 
(NXTimeInterval- compare:
 Compares the date against another date, and returns the difference. More...
 
(BOOL- isEarlierThan:
 Determine if the date is earlier than another date. More...
 
(BOOL- isLaterThan:
 Determine if the date is later than another date. More...
 
(void) - addTimeInterval:
 Add a time interval to this date. More...
 
(NXDate *) - dateByAddingTimeInterval:
 Return a new date by adding a time interval to this date. More...
 
- Instance Methods inherited from NXObject
(id- retain
 Increases the retain count of the receiver. More...
 
(void) - release
 Decreases the retain count of the receiver. More...
 
(id- autorelease
 Adds the receiver to the autorelease pool.
 
- Instance Methods inherited from Object
(void) - dealloc
 Free resources for an existing instance.
 
(id- init
 Initialize the instance, after allocation. More...
 
(Class- class
 Returns the class of the instance. More...
 
(Class- superclass
 Returns the superclass of the instance. More...
 
(BOOL- isEqual:
 Compares the receiver to another object for equality. 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...
 
(NXString *) - description
 Returns a string that represents the instance. More...
 
- Instance Methods inherited from <ObjectProtocol>
(BOOL- respondsToSelector:
 Checks if the receiver responds to a selector. More...
 
- Instance Methods inherited from <JSONProtocol>
(NXString *) - JSONString
 Returns a JSON representation of the instance. More...
 
(size_t) - JSONBytes
 Returns the appropriate capacity for the JSON representation of the instance. More...
 

Class Methods

(NXDate *) + date
 Creates and returns a new date set to the current date and time. More...
 
(NXDate *) + dateWithTimeIntervalSinceNow:
 Creates and returns a date object set to a given time interval from now. More...
 
- Class Methods inherited from NXObject
(id+ allocWithZone:
 Allocates a new instance of an object in a specific memory zone. More...
 
- Class Methods inherited from Object
(void) + initialize
 Performs one-time initialization for the class. More...
 
(id+ alloc
 Allocate a new class instance. 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...
 
(NXString *) + description
 Returns a string that represents the class. More...
 

Protected Attributes

sys_date_t _date
 Date and time representation.
 
- Protected Attributes inherited from NXObject
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.
 
- Protected Attributes inherited from Object
Class isa
 A pointer to the object's class structure. More...
 

Detailed Description

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.

Method Documentation

◆ addTimeInterval:()

- (void) addTimeInterval: (NXTimeInterval interval

Add a time interval to this date.

Parameters
intervalThe time interval to add.

◆ compare:()

- (NXTimeInterval) compare: (NXDate *)  otherDate

Compares the date against another date, and returns the difference.

Parameters
otherDateThe date to compare against.
Returns
The time interval since the reference date. If the other date is later, the interval will be negative.

◆ date()

+ (NXDate *) 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:()

- (NXDate *) dateByAddingTimeInterval: (NXTimeInterval interval

Return a new date by adding a time interval to this date.

Parameters
intervalThe time interval to add.
Returns
A new NXDate instance representing the date after adding the interval.

◆ dateWithTimeIntervalSinceNow:()

+ (NXDate *) dateWithTimeIntervalSinceNow: (NXTimeInterval interval

Creates and returns a date object set to a given time interval from now.

Parameters
intervalThe 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
hoursPointer to store the hours (0-23). Can be NULL if not needed.
minutesPointer to store the minutes (0-59). Can be NULL if not needed.
secondsPointer to store the seconds (0-59). Can be NULL if not needed.
nanosecondsPointer 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:()

- (BOOL) isEarlierThan: (NXDate *)  otherDate

Determine if the date is earlier than another date.

Parameters
otherDateThe date to compare against.
Returns
YES if this date is earlier than otherDate, NO otherwise.

◆ isLaterThan:()

- (BOOL) isLaterThan: (NXDate *)  otherDate

Determine if the date is later than another date.

Parameters
otherDateThe 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
hoursThe hours to set (0-23).
minutesThe minutes to set (0-59).
secondsThe seconds to set (0-59).
nanosecondsThe 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
yearThe year to set (e.g., 2025).
monthThe month to set (1-12).
dayThe 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
yearPointer to store the year (e.g., 2025). Can be NULL if not needed.
monthPointer to store the month (1-12). Can be NULL if not needed.
dayPointer to store the day of month (1-31). Can be NULL if not needed.
weekdayPointer 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: