ObjFW
OFDate.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
3  * Jonathan Schleifer <js@webkeks.org>
4  *
5  * All rights reserved.
6  *
7  * This file is part of ObjFW. It may be distributed under the terms of the
8  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
9  * the packaging of this file.
10  *
11  * Alternatively, it may be distributed under the terms of the GNU General
12  * Public License, either version 2 or 3, which can be found in the file
13  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
14  * file.
15  */
16 
17 #import "OFObject.h"
18 #import "OFSerialization.h"
19 
20 OF_ASSUME_NONNULL_BEGIN
21 
22 @class OFString;
23 @class OFConstantString;
24 
31 {
32  of_time_interval_t _seconds;
33 }
34 
40 + (instancetype)date;
41 
49 + (instancetype)dateWithTimeIntervalSince1970: (of_time_interval_t)seconds;
50 
57 + (instancetype)dateWithTimeIntervalSinceNow: (of_time_interval_t)seconds;
58 
75 + (instancetype)dateWithDateString: (OFString*)string
76  format: (OFString*)format;
77 
91 + (instancetype)dateWithLocalDateString: (OFString*)string
92  format: (OFString*)format;
93 
101 + (instancetype)distantFuture;
102 
110 + (instancetype)distantPast;
111 
119 - initWithTimeIntervalSince1970: (of_time_interval_t)seconds;
120 
128 - initWithTimeIntervalSinceNow: (of_time_interval_t)seconds;
129 
147 - initWithDateString: (OFString*)string
148  format: (OFString*)format;
149 
165 - initWithLocalDateString: (OFString*)string
166  format: (OFString*)format;
167 
173 - (uint32_t)microsecond;
174 
180 - (uint8_t)second;
181 
187 - (uint8_t)minute;
188 
194 - (uint8_t)hour;
195 
201 - (uint8_t)localHour;
202 
208 - (uint8_t)dayOfMonth;
209 
215 - (uint8_t)localDayOfMonth;
216 
222 - (uint8_t)monthOfYear;
223 
229 - (uint8_t)localMonthOfYear;
230 
236 - (uint16_t)year;
237 
243 - (uint16_t)localYear;
244 
250 - (uint8_t)dayOfWeek;
251 
257 - (uint8_t)localDayOfWeek;
258 
264 - (uint16_t)dayOfYear;
265 
271 - (uint16_t)localDayOfYear;
272 
281 - (OFString*)dateStringWithFormat: (OFConstantString*)format;
282 
291 - (OFString*)localDateStringWithFormat: (OFConstantString*)format;
292 
301 - (OFDate*)earlierDate: (OFDate*)otherDate;
302 
311 - (OFDate*)laterDate: (OFDate*)otherDate;
312 
318 - (of_time_interval_t)timeIntervalSince1970;
319 
326 - (of_time_interval_t)timeIntervalSinceDate: (OFDate*)otherDate;
327 
333 - (of_time_interval_t)timeIntervalSinceNow;
334 
341 - (OFDate*)dateByAddingTimeInterval: (of_time_interval_t)seconds;
342 @end
343 
344 OF_ASSUME_NONNULL_END
A protocol for serializing objects.
Definition: OFSerialization.h:30
A protocol for comparing objects.
Definition: OFObject.h:933
A class for storing, accessing and comparing dates.
Definition: OFDate.h:30
A class for storing constant strings using the @"" literal.
Definition: OFConstantString.h:37
The root class for all other classes inside ObjFW.
Definition: OFObject.h:364
A class for handling strings.
Definition: OFString.h:91
A protocol for the creation of copies.
Definition: OFObject.h:896
double of_time_interval_t
A time interval in seconds.
Definition: OFObject.h:90