ObjFW
Loading...
Searching...
No Matches
OFDate.h
1/*
2 * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3 *
4 * All rights reserved.
5 *
6 * This file is part of ObjFW. It may be distributed under the terms of the
7 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8 * the packaging of this file.
9 *
10 * Alternatively, it may be distributed under the terms of the GNU General
11 * Public License, either version 2 or 3, which can be found in the file
12 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13 * file.
14 */
15
16#import "OFObject.h"
17#import "OFMessagePackRepresentation.h"
18
19OF_ASSUME_NONNULL_BEGIN
20
21@class OFString;
22@class OFConstantString;
23
31#ifdef OF_HAVE_CLASS_PROPERTIES
32@property (class, readonly, nonatomic) OFDate *distantFuture;
33@property (class, readonly, nonatomic) OFDate *distantPast;
34#endif
35
39@property (readonly, nonatomic) unsigned long microsecond;
40
44@property (readonly, nonatomic) unsigned char second;
45
49@property (readonly, nonatomic) unsigned char minute;
50
54@property (readonly, nonatomic) unsigned char localMinute;
55
59@property (readonly, nonatomic) unsigned char hour;
60
64@property (readonly, nonatomic) unsigned char localHour;
65
69@property (readonly, nonatomic) unsigned char dayOfMonth;
70
74@property (readonly, nonatomic) unsigned char localDayOfMonth;
75
79@property (readonly, nonatomic) unsigned char monthOfYear;
80
84@property (readonly, nonatomic) unsigned char localMonthOfYear;
85
89@property (readonly, nonatomic) unsigned short year;
90
94@property (readonly, nonatomic) unsigned short localYear;
95
99@property (readonly, nonatomic) unsigned char dayOfWeek;
100
104@property (readonly, nonatomic) unsigned char localDayOfWeek;
105
109@property (readonly, nonatomic) unsigned short dayOfYear;
110
114@property (readonly, nonatomic) unsigned short localDayOfYear;
115
119@property (readonly, nonatomic) OFTimeInterval timeIntervalSince1970;
120
124@property (readonly, nonatomic) OFTimeInterval timeIntervalSinceNow;
125
131+ (instancetype)date;
132
140+ (instancetype)dateWithTimeIntervalSince1970: (OFTimeInterval)seconds;
141
148+ (instancetype)dateWithTimeIntervalSinceNow: (OFTimeInterval)seconds;
149
168+ (instancetype)dateWithDateString: (OFString *)string
169 format: (OFString *)format;
170
186+ (instancetype)dateWithLocalDateString: (OFString *)string
187 format: (OFString *)format;
188
196+ (instancetype)distantFuture;
197
205+ (instancetype)distantPast;
206
214- (instancetype)initWithTimeIntervalSince1970: (OFTimeInterval)seconds
215 OF_DESIGNATED_INITIALIZER;
216
224- (instancetype)initWithTimeIntervalSinceNow: (OFTimeInterval)seconds;
225
244- (instancetype)initWithDateString: (OFString *)string
245 format: (OFString *)format;
246
263- (instancetype)initWithLocalDateString: (OFString *)string
264 format: (OFString *)format;
265
272- (OFComparisonResult)compare: (OFDate *)date;
273
287- (OFString *)dateStringWithFormat: (OFConstantString *)format;
288
302- (OFString *)localDateStringWithFormat: (OFConstantString *)format;
303
312- (OFDate *)earlierDate: (nullable OFDate *)otherDate;
313
322- (OFDate *)laterDate: (nullable OFDate *)otherDate;
323
330- (OFTimeInterval)timeIntervalSinceDate: (OFDate *)otherDate;
331
338- (OFDate *)dateByAddingTimeInterval: (OFTimeInterval)seconds;
339@end
340
341OF_ASSUME_NONNULL_END
OFComparisonResult
A result of a comparison.
Definition OFObject.h:54
double OFTimeInterval
A time interval in seconds.
Definition OFObject.h:150
A class for storing constant strings using the @"" literal.
Definition OFConstantString.h:38
A class for storing, accessing and comparing dates.
Definition OFDate.h:30
instancetype distantFuture()
Returns a date in the distant future.
Definition OFDate.m:366
unsigned char dayOfMonth
The day of the month of the date.
Definition OFDate.h:69
unsigned char localDayOfMonth
The day of the month of the date in local time.
Definition OFDate.h:74
unsigned char monthOfYear
The month of the year of the date.
Definition OFDate.h:79
unsigned char localMonthOfYear
The month of the year of the date in local time.
Definition OFDate.h:84
unsigned long microsecond
The microsecond of the date.
Definition OFDate.h:39
instancetype date()
Creates a new OFDate with the current date and time.
Definition OFDate.m:335
unsigned char dayOfWeek
The day of the week of the date.
Definition OFDate.h:99
unsigned short dayOfYear
The day of the year of the date.
Definition OFDate.h:109
unsigned char localMinute
The minute of the date in local time.
Definition OFDate.h:54
OFTimeInterval timeIntervalSince1970
The seconds since 1970-01-01T00:00:00Z.
Definition OFDate.h:119
unsigned short year
The year of the date.
Definition OFDate.h:89
unsigned short localYear
The year of the date in local time.
Definition OFDate.h:94
unsigned char minute
The minute of the date.
Definition OFDate.h:49
instancetype distantPast()
Returns a date in the distant past.
Definition OFDate.m:373
unsigned char hour
The hour of the date.
Definition OFDate.h:59
unsigned char localDayOfWeek
The day of the week of the date in local time.
Definition OFDate.h:104
unsigned char localHour
The hour of the date in local time.
Definition OFDate.h:64
OFTimeInterval timeIntervalSinceNow
The seconds the date is in the future.
Definition OFDate.h:124
unsigned char second
The second of the date.
Definition OFDate.h:44
unsigned short localDayOfYear
The day of the year of the date in local time.
Definition OFDate.h:114
The root class for all other classes inside ObjFW.
Definition OFObject.h:688
A class for handling strings.
Definition OFString.h:135
A protocol for comparing objects.
Definition OFObject.h:1384
A protocol for the creation of copies.
Definition OFObject.h:1346
A protocol implemented by classes that support encoding to a MessagePack representation.
Definition OFMessagePackRepresentation.h:29