ObjFW  Diff

Differences From Artifact [09915d0305]:

To Artifact [267ceb61ed]:


16
17
18
19
20
21
22
23
24


25
26
27
28
29
30
31
32


33
34

35
36
37
38
39


40
41
42
43


44
45
46
47
48


49
50
51


52
53
54
55
56


57
58
59
60
61
62
63
64

65
66
67
68
69



70
71
72
73
74
75


76
77
78
79
80

81
82
83
84
85



86
87
88
89
90
91


92
93
94
95

96
97
98
99
100


101
102
103
104

105
106
107
108
109


110
111
112
113


114
115
116
117
118


119
120
121
122


123
124
125
126
127


128
129
130
131
132
133
134
135
136

137
138
139
140
141



142
143
144
145
146
147


148
149
150
151
152
153
154

155
156
157
158
159



160
161
162
163
164
165


166
167

168
169
170
171
172


173
174

175
176
177
178
179


180
181

182
183
184
185
186


187
188

189
190
191
192
193


194
195

196
197
198
199
200


201
202

203
204
205
206
207


208
209

210
211
212
213
214


215
216

217
218
219
220
221


222
223

224
225
226
227
228


229
230

231
232
233
234
235


236
237

238
239
240
241
242


243
244

245
246
247
248
249


250
251

252
253
254
255
256


257
258

259
260
261
262
263


264
265

266
267
268
269
270


271
272
273
274
275


276
277
278
279
280


281
282
283
284
285


286
287
288
289
290


291
292
293


294
295
296
297
298


299
300
301


302
303
304
305
306


307
308

309
310
311
312
313


314
315
316


317
318
319
320
321


322
323

324
325
326
327
328


329
330
331


332
333
334
16
17
18
19
20
21
22


23
24
25
26
27
28
29
30


31
32
33

34
35
36
37


38
39
40
41


42
43
44
45
46


47
48
49


50
51
52
53
54


55
56
57
58
59
60
61
62
63

64
65
66



67
68
69
70
71
72
73


74
75
76
77
78
79

80
81
82



83
84
85
86
87
88
89


90
91
92
93
94

95
96
97
98


99
100
101
102
103

104
105
106
107


108
109
110
111


112
113
114
115
116


117
118
119
120


121
122
123
124
125


126
127
128
129
130
131
132
133
134
135

136
137
138



139
140
141
142
143
144
145


146
147
148
149
150
151
152
153

154
155
156



157
158
159
160
161
162
163


164
165
166

167
168
169
170


171
172
173

174
175
176
177


178
179
180

181
182
183
184


185
186
187

188
189
190
191


192
193
194

195
196
197
198


199
200
201

202
203
204
205


206
207
208

209
210
211
212


213
214
215

216
217
218
219


220
221
222

223
224
225
226


227
228
229

230
231
232
233


234
235
236

237
238
239
240


241
242
243

244
245
246
247


248
249
250

251
252
253
254


255
256
257

258
259
260
261


262
263
264

265
266
267
268


269
270
271
272
273


274
275
276
277
278


279
280
281
282
283


284
285
286
287
288


289
290
291


292
293
294
295
296


297
298
299


300
301
302
303
304


305
306
307

308
309
310
311


312
313
314


315
316
317
318
319


320
321
322

323
324
325
326


327
328
329


330
331
332
333
334







-
-
+
+






-
-
+
+

-
+



-
-
+
+


-
-
+
+



-
-
+
+

-
-
+
+



-
-
+
+







-
+


-
-
-
+
+
+




-
-
+
+




-
+


-
-
-
+
+
+




-
-
+
+



-
+



-
-
+
+



-
+



-
-
+
+


-
-
+
+



-
-
+
+


-
-
+
+



-
-
+
+








-
+


-
-
-
+
+
+




-
-
+
+






-
+


-
-
-
+
+
+




-
-
+
+

-
+



-
-
+
+

-
+



-
-
+
+

-
+



-
-
+
+

-
+



-
-
+
+

-
+



-
-
+
+

-
+



-
-
+
+

-
+



-
-
+
+

-
+



-
-
+
+

-
+



-
-
+
+

-
+



-
-
+
+

-
+



-
-
+
+

-
+



-
-
+
+

-
+



-
-
+
+

-
+



-
-
+
+

-
+



-
-
+
+



-
-
+
+



-
-
+
+



-
-
+
+



-
-
+
+

-
-
+
+



-
-
+
+

-
-
+
+



-
-
+
+

-
+



-
-
+
+

-
-
+
+



-
-
+
+

-
+



-
-
+
+

-
-
+
+




#import "OFObject.h"
#import "OFSerialization.h"

@class OFString;
@class OFConstantString;

/**
 * \brief A class for storing, accessing and comparing dates.
/*!
 * @brief A class for storing, accessing and comparing dates.
 */
@interface OFDate: OFObject <OFCopying, OFComparing, OFSerialization>
{
	double seconds;
}

/**
 * \brief Creates a new OFDate with the current date and time.
/*!
 * @brief Creates a new OFDate with the current date and time.
 *
 * \return A new, autoreleased OFDate with the current date and time
 * @return A new, autoreleased OFDate with the current date and time
 */
+ (instancetype)date;

/**
 * \brief Creates a new OFDate with the specified date and time since
/*!
 * @brief Creates a new OFDate with the specified date and time since
 *	  1970-01-01T00:00:00Z.
 *
 * \param seconds The seconds since 1970-01-01T00:00:00Z
 * \return A new, autoreleased OFDate with the specified date and time
 * @param seconds The seconds since 1970-01-01T00:00:00Z
 * @return A new, autoreleased OFDate with the specified date and time
 */
+ (instancetype)dateWithTimeIntervalSince1970: (double)seconds;

/**
 * \brief Creates a new OFDate with the specified date and time since now.
/*!
 * @brief Creates a new OFDate with the specified date and time since now.
 *
 * \param seconds The seconds since now
 * \return A new, autoreleased OFDate with the specified date and time
 * @param seconds The seconds since now
 * @return A new, autoreleased OFDate with the specified date and time
 */
+ (instancetype)dateWithTimeIntervalSinceNow: (double)seconds;

/**
 * \brief Creates a new OFDate with the specified string in the specified
/*!
 * @brief Creates a new OFDate with the specified string in the specified
 *	  format.
 *
 * The time zone used is UTC. See +[dateWithLocalDateString:format:] if you
 * want local time.
 *
 * See the manpage for strftime for information on the format.
 *
 * \warning The format is currently limited to the following format specifiers:
 * @warning The format is currently limited to the following format specifiers:
 *	    %%d, %%e, %%H, %%m, %%M, %%S, %%y, %%Y, %%, %%n and %%t.
 *
 * \param string The string describing the date
 * \param format The format of the string describing the date
 * \return A new, autoreleased OFDate with the specified date and time
 * @param string The string describing the date
 * @param format The format of the string describing the date
 * @return A new, autoreleased OFDate with the specified date and time
 */
+ (instancetype)dateWithDateString: (OFString*)string
			    format: (OFString*)format;

/**
 * \brief Creates a new OFDate with the specified string in the specified
/*!
 * @brief Creates a new OFDate with the specified string in the specified
 *	  format.
 *
 * See the manpage for strftime for information on the format.
 *
 * \warning The format is currently limited to the following format specifiers:
 * @warning The format is currently limited to the following format specifiers:
 *	    %%d, %%e, %%H, %%m, %%M, %%S, %%y, %%Y, %%, %%n and %%t.
 *
 * \param string The string describing the date
 * \param format The format of the string describing the date
 * \return A new, autoreleased OFDate with the specified date and time
 * @param string The string describing the date
 * @param format The format of the string describing the date
 * @return A new, autoreleased OFDate with the specified date and time
 */
+ (instancetype)dateWithLocalDateString: (OFString*)string
				 format: (OFString*)format;

/**
 * \brief Returns a date in the distant future.
/*!
 * @brief Returns a date in the distant future.
 *
 * The date is system-dependant.
 *
 * \return A date in the distant future
 * @return A date in the distant future
 */
+ (instancetype)distantFuture;

/**
 * \brief Returns a date in the distant past.
/*!
 * @brief Returns a date in the distant past.
 *
 * The date is system-dependant.
 *
 * \return A date in the distant past
 * @return A date in the distant past
 */
+ (instancetype)distantPast;

/**
 * \brief Initializes an already allocated OFDate with the specified date and
/*!
 * @brief Initializes an already allocated OFDate with the specified date and
 *	  time since 1970-01-01T00:00:00Z.
 *
 * \param seconds The seconds since 1970-01-01T00:00:00Z
 * \return An initialized OFDate with the specified date and time
 * @param seconds The seconds since 1970-01-01T00:00:00Z
 * @return An initialized OFDate with the specified date and time
 */
- initWithTimeIntervalSince1970: (double)seconds;

/**
 * \brief Initializes an already allocated OFDate with the specified date and
/*!
 * @brief Initializes an already allocated OFDate with the specified date and
 *	  time since now.
 *
 * \param seconds The seconds since now
 * \return An initialized OFDate with the specified date and time
 * @param seconds The seconds since now
 * @return An initialized OFDate with the specified date and time
 */
- initWithTimeIntervalSinceNow: (double)seconds;

/**
 * \brief Initializes an already allocated OFDate with the specified string in
/*!
 * @brief Initializes an already allocated OFDate with the specified string in
 *	  the specified format.
 *
 * The time zone used is UTC. If a time zone is specified anyway, an
 * OFInvalidFormatException is thrown. See -[initWithLocalDateString:format:]
 * if you want to specify a time zone.
 *
 * See the manpage for strftime for information on the format.
 *
 * \warning The format is currently limited to the following format specifiers:
 * @warning The format is currently limited to the following format specifiers:
 *	    %%d, %%e, %%H, %%m, %%M, %%S, %%y, %%Y, %%, %%n and %%t.
 *
 * \param string The string describing the date
 * \param format The format of the string describing the date
 * \return An initialized OFDate with the specified date and time
 * @param string The string describing the date
 * @param format The format of the string describing the date
 * @return An initialized OFDate with the specified date and time
 */
- initWithDateString: (OFString*)string
	      format: (OFString*)format;

/**
 * \brief Initializes an already allocated OFDate with the specified string in
/*!
 * @brief Initializes an already allocated OFDate with the specified string in
 *	  the specified format.
 *
 * If no time zone is specified, local time is assumed.
 *
 * See the manpage for strftime for information on the format.
 *
 * \warning The format is currently limited to the following format specifiers:
 * @warning The format is currently limited to the following format specifiers:
 *	    %%d, %%e, %%H, %%m, %%M, %%S, %%y, %%Y, %%, %%n and %%t.
 *
 * \param string The string describing the date
 * \param format The format of the string describing the date
 * \return An initialized OFDate with the specified date and time
 * @param string The string describing the date
 * @param format The format of the string describing the date
 * @return An initialized OFDate with the specified date and time
 */
- initWithLocalDateString: (OFString*)string
		   format: (OFString*)format;

/**
 * \brief Returns the microsecond of the date.
/*!
 * @brief Returns the microsecond of the date.
 *
 * \return The microsecond of the date
 * @return The microsecond of the date
 */
- (uint32_t)microsecond;

/**
 * \brief Returns the second of the date.
/*!
 * @brief Returns the second of the date.
 *
 * \return The second of the date
 * @return The second of the date
 */
- (uint8_t)second;

/**
 * \brief Returns the minute of the date.
/*!
 * @brief Returns the minute of the date.
 *
 * \return The minute of the date
 * @return The minute of the date
 */
- (uint8_t)minute;

/**
 * \brief Returns the hour of the date.
/*!
 * @brief Returns the hour of the date.
 *
 * \return The hour of the date
 * @return The hour of the date
 */
- (uint8_t)hour;

/**
 * \brief Returns the hour of the date in local time.
/*!
 * @brief Returns the hour of the date in local time.
 *
 * \return The hour of the date in local time
 * @return The hour of the date in local time
 */
- (uint8_t)localHour;

/**
 * \brief Returns the day of the month.
/*!
 * @brief Returns the day of the month.
 *
 * \return The day of the month of the date
 * @return The day of the month of the date
 */
- (uint8_t)dayOfMonth;

/**
 * \brief Returns the day of the month of the date in local time.
/*!
 * @brief Returns the day of the month of the date in local time.
 *
 * \return The day of the month of the date in local time
 * @return The day of the month of the date in local time
 */
- (uint8_t)localDayOfMonth;

/**
 * \brief Returns the month of the year of the date.
/*!
 * @brief Returns the month of the year of the date.
 *
 * \return The month of the year of the date
 * @return The month of the year of the date
 */
- (uint8_t)monthOfYear;

/**
 * \brief Returns the month of the year of the date in local time.
/*!
 * @brief Returns the month of the year of the date in local time.
 *
 * \return The month of the year of the date in local time
 * @return The month of the year of the date in local time
 */
- (uint8_t)localMonthOfYear;

/**
 * \brief Returns the year of the date.
/*!
 * @brief Returns the year of the date.
 *
 * \return The year of the date
 * @return The year of the date
 */
- (uint16_t)year;

/**
 * \brief Returns the year of the date in local time.
/*!
 * @brief Returns the year of the date in local time.
 *
 * \return The year of the date in local time
 * @return The year of the date in local time
 */
- (uint16_t)localYear;

/**
 * \brief Returns the day of the week of the date.
/*!
 * @brief Returns the day of the week of the date.
 *
 * \return The day of the week of the date
 * @return The day of the week of the date
 */
- (uint8_t)dayOfWeek;

/**
 * \brief Returns the day of the week of the date in local time.
/*!
 * @brief Returns the day of the week of the date in local time.
 *
 * \return The day of the week of the date in local time
 * @return The day of the week of the date in local time
 */
- (uint8_t)localDayOfWeek;

/**
 * \brief Returns the day of the year of the date.
/*!
 * @brief Returns the day of the year of the date.
 *
 * \return The day of the year of the date
 * @return The day of the year of the date
 */
- (uint16_t)dayOfYear;

/**
 * \brief Returns the day of the year of the date in local time.
/*!
 * @brief Returns the day of the year of the date in local time.
 *
 * \return The day of the year of the date in local time
 * @return The day of the year of the date in local time
 */
- (uint16_t)localDayOfYear;

/**
 * \brief Creates a string of the date with the specified format.
/*!
 * @brief Creates a string of the date with the specified format.
 *
 * See the manpage for strftime for information on the format.
 *
 * \param format The format for the date string
 * \return A new, autoreleased OFString
 * @param format The format for the date string
 * @return A new, autoreleased OFString
 */
- (OFString*)dateStringWithFormat: (OFConstantString*)format;

/**
 * \brief Creates a string of the local date with the specified format.
/*!
 * @brief Creates a string of the local date with the specified format.
 *
 * See the manpage for strftime for information on the format.
 *
 * \param format The format for the date string
 * \return A new, autoreleased OFString
 * @param format The format for the date string
 * @return A new, autoreleased OFString
 */
- (OFString*)localDateStringWithFormat: (OFConstantString*)format;

/**
 * \brief Returns the earlier of the two dates.
/*!
 * @brief Returns the earlier of the two dates.
 *
 * \param date Another date
 * \return The earlier date of the two dates
 * @param date Another date
 * @return The earlier date of the two dates
 */
- (OFDate*)earlierDate: (OFDate*)otherDate;

/**
 * \brief Returns the later of the two dates.
/*!
 * @brief Returns the later of the two dates.
 *
 * \param date Another date
 * \return The later date of the two dates
 * @param date Another date
 * @return The later date of the two dates
 */
- (OFDate*)laterDate: (OFDate*)otherDate;

/**
 * \brief Returns the seconds since 1970-01-01T00:00:00Z.
/*!
 * @brief Returns the seconds since 1970-01-01T00:00:00Z.
 *
 * \return The seconds since 1970-01-01T00:00:00Z
 * @return The seconds since 1970-01-01T00:00:00Z
 */
- (double)timeIntervalSince1970;

/**
 * \brief Returns the seconds the receiver is after the date.
/*!
 * @brief Returns the seconds the receiver is after the date.
 *
 * \param date Date date to generate the difference with receiver
 * \return The seconds the receiver is after the date.
 * @param date Date date to generate the difference with receiver
 * @return The seconds the receiver is after the date.
 */
- (double)timeIntervalSinceDate: (OFDate*)otherDate;

/**
 * \brief Returns the seconds the receiver is in the future.
/*!
 * @brief Returns the seconds the receiver is in the future.
 *
 * \return The seconds the receiver is in the future
 * @return The seconds the receiver is in the future
 */
- (double)timeIntervalSinceNow;

/**
 * \brief Creates a new date with the specified time interval added.
/*!
 * @brief Creates a new date with the specified time interval added.
 *
 * \param seconds The seconds after the date
 * \return A new, autoreleased OFDate
 * @param seconds The seconds after the date
 * @return A new, autoreleased OFDate
 */
- (OFDate*)dateByAddingTimeInterval: (double)seconds;
@end