picofuse-objc

NXDate.h
Go to the documentation of this file.
1 
5 #pragma once
6 #include "NXComparisonResult.h"
7 #include "NXDuration.h"
8 #include <picofuse/sys.h>
9 #include <stdint.h>
10 
17 typedef enum {
18  NXDateFormatISO8601 = sys_date_format_iso8601,
19  NXDateFormatRFC2822 = sys_date_format_rfc2822,
21  NXDateFormatLog = sys_date_format_log,
23 } NXDateFormat;
25 
44 @interface NXDate : NXObject {
45 @private
46  sys_date_t _date;
47 }
48 
52 + (id)date;
53 
58 + (id)dateWithDuration:(NXDuration)duration;
59 
67 + (id)dateWithSeconds:(int64_t)seconds nanoseconds:(int32_t)nanoseconds;
68 
75 + (id)dateWithYear:(uint16_t)year month:(uint8_t)month day:(uint8_t)day;
76 
86 + (id)dateWithYear:(uint16_t)year
87  month:(uint8_t)month
88  day:(uint8_t)day
89  hours:(uint8_t)hours
90  minutes:(uint8_t)minutes
91  seconds:(uint8_t)seconds;
92 
106 + (id)dateWithString:(NXString *)string format:(NXDateFormat)format;
107 
112 + (id)dateWithString:(NXString *)string;
113 
120 + (BOOL)setCurrentDate:(NXDate *)date;
121 
125 - (id)init;
126 
130 - (id)initWithSeconds:(int64_t)seconds nanoseconds:(int32_t)nanoseconds;
131 
135 - (id)initWithYear:(uint16_t)year
136  month:(uint8_t)month
137  day:(uint8_t)day
138  hours:(uint8_t)hours
139  minutes:(uint8_t)minutes
140  seconds:(uint8_t)seconds;
141 
145 - (id)initWithString:(NXString *)string format:(NXDateFormat)format;
146 
151 - (int64_t)seconds;
152 
156 - (int32_t)nanoseconds;
157 
161 - (int32_t)timeZoneOffset;
162 
168 - (NXDate *)dateWithTimeZoneOffset:(int32_t)offset;
169 
174 - (NXDate *)dateByAddingDuration:(NXDuration)duration;
175 
182 - (NXDuration)durationSinceDate:(NXDate *)other;
183 
190 - (NXComparisonResult)compare:(NXDate *)other;
191 
195 - (BOOL)isEqual:(id)anObject;
196 
201 - (uintptr_t)hash;
202 
211 - (BOOL)year:(uint16_t *)year
212  month:(uint8_t *)month
213  day:(uint8_t *)day
214  weekday:(uint8_t *)weekday;
215 
220 - (BOOL)hours:(uint8_t *)hours minutes:(uint8_t *)minutes seconds:(uint8_t *)seconds;
221 
226 - (BOOL)localYear:(uint16_t *)year
227  month:(uint8_t *)month
228  day:(uint8_t *)day
229  weekday:(uint8_t *)weekday;
230 
235 - (BOOL)localHours:(uint8_t *)hours
236  minutes:(uint8_t *)minutes
237  seconds:(uint8_t *)seconds;
238 
243 - (NXString *)stringWithFormat:(NXDateFormat)format;
244 
249 - (NXString *)description;
250 
251 @end
int32_t timeZoneOffset()
Returns the offset of the time zone, in seconds east of UTC.
Defines the NXDuration type, and constants for units of time.
uintptr_t hash()
Returns a hash of the moment, which is the same for equal dates, whatever their time zones...
int64_t seconds()
Returns the number of whole seconds since 1970-01-01 in UTC, which is negative before then...
int64_t NXDuration
A length of time, in nanoseconds, which may be negative.
Definition: NXDuration.h:17
NXString * description()
Returns the date in ISO 8601, such as "2026-09-06T11:37:05Z", or nil if the year isn&#39;t from 0 to 6553...
id init()
Initializes the current date.
"Sun, 06 Sep 2026 11:37:05 GMT", as in HTTP, always in UTC
Definition: NXDate.h:20
int32_t nanoseconds()
Returns the nanoseconds after the seconds, from zero to 999999999.
A date and time, to the nanosecond, with the offset of a time zone.
Definition: NXDate.h:44
NXComparisonResult
The order of two objects.
bool BOOL
A Boolean value.
Definition: runtime.h:60
NXDateFormat
Ways of writing a date.
Definition: NXDate.h:17
A string of UTF-8 text.
Definition: NXString.h:53
"2026-09-06 11:37:05", always in UTC
Definition: NXDate.h:22
Defines the NXComparisonResult type, for the result of a comparison.
The base class for objects in the Foundation framework.
Definition: NXObject.h:28
struct objc_object * id
A pointer to an instance of a class.
Definition: runtime.h:18
"2026-09-06T11:37:05Z", or with an offset such as "+01:00"
Definition: NXDate.h:18
id date()
Returns the current date, or nil if the clock can&#39;t be read.