ObjFW  Diff

Differences From Artifact [97a4e4b983]:

To Artifact [fed9345cd2]:


20
21
22
23
24
25
26


27
28
29
30
31
32
33
#include <limits.h>
#include <time.h>

#include <sys/time.h>

#import "OFDate.h"
#import "OFString.h"


#import "OFAutoreleasePool.h"
#ifdef OF_THREADS
# import "OFThread.h"
#endif

#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"







>
>







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <limits.h>
#include <time.h>

#include <sys/time.h>

#import "OFDate.h"
#import "OFString.h"
#import "OFDictionary.h"
#import "OFNumber.h"
#import "OFAutoreleasePool.h"
#ifdef OF_THREADS
# import "OFThread.h"
#endif

#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
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
}

- copy
{
	return [self retain];
}

- (of_comparison_result_t)compare: (id)obj
{
	OFDate *otherDate;

	if (![obj isKindOfClass: [OFDate class]])
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	otherDate = (OFDate*)obj;

	if (seconds < otherDate->seconds)
		return OF_ORDERED_ASCENDING;
	if (seconds > otherDate->seconds)
		return OF_ORDERED_DESCENDING;

	if (microseconds < otherDate->microseconds)
		return OF_ORDERED_ASCENDING;
	if (microseconds > otherDate->microseconds)
		return OF_ORDERED_DESCENDING;

	return OF_ORDERED_SAME;
}

- (OFString*)description
{
	return [self dateStringWithFormat: @"%Y-%m-%dT%H:%M:%SZ"];
}




















- (uint32_t)microsecond
{
	return microseconds;
}

- (uint8_t)second







|



|



|


















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
}

- copy
{
	return [self retain];
}

- (of_comparison_result_t)compare: (id)object
{
	OFDate *otherDate;

	if (![object isKindOfClass: [OFDate class]])
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	otherDate = (OFDate*)object;

	if (seconds < otherDate->seconds)
		return OF_ORDERED_ASCENDING;
	if (seconds > otherDate->seconds)
		return OF_ORDERED_DESCENDING;

	if (microseconds < otherDate->microseconds)
		return OF_ORDERED_ASCENDING;
	if (microseconds > otherDate->microseconds)
		return OF_ORDERED_DESCENDING;

	return OF_ORDERED_SAME;
}

- (OFString*)description
{
	return [self dateStringWithFormat: @"%Y-%m-%dT%H:%M:%SZ"];
}

- (OFString*)stringBySerializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFDictionary *dictionary = [OFDictionary dictionaryWithKeysAndObjects:
	    @"seconds", [OFNumber numberWithInt64: seconds],
	    @"microseconds", [OFNumber numberWithUInt32: microseconds], nil];
	OFString *ret = [[OFString alloc]
	    initWithFormat: @"(class=OFDate,version=0)<%@>",
			    [dictionary stringBySerializing]];

	@try {
		[pool release];
	} @finally {
		[ret autorelease];
	}

	return ret;
}

- (uint32_t)microsecond
{
	return microseconds;
}

- (uint8_t)second