ObjFW  Diff

Differences From Artifact [e749446c20]:

To Artifact [d311cf12a2]:


185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
	return [[[self alloc] initWithLocalDateString: string
					       format: format] autorelease];
}

+ (instancetype)distantFuture
{
	return [[[self alloc]
	    initWithTimeIntervalSince1970: DBL_MAX] autorelease];
}

+ (instancetype)distantPast
{
	return [[[self alloc]
	    initWithTimeIntervalSince1970: DBL_MIN] autorelease];
}

- init
{
	struct timeval t;

	self = [super init];







|





|







185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
	return [[[self alloc] initWithLocalDateString: string
					       format: format] autorelease];
}

+ (instancetype)distantFuture
{
	return [[[self alloc]
	    initWithTimeIntervalSince1970: INFINITY] autorelease];
}

+ (instancetype)distantPast
{
	return [[[self alloc]
	    initWithTimeIntervalSince1970: -INFINITY] autorelease];
}

- init
{
	struct timeval t;

	self = [super init];
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

- initWithSerialization: (OFXMLElement*)element
{
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();

		union {
			double d;
			uint64_t u;
		} d;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException exception];








		d.u = (uint64_t)[element hexadecimalValue];
		_seconds = d.d;


		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;
	}








>









>
>
>
>
>
>
>
|
|
>







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

- initWithSerialization: (OFXMLElement*)element
{
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();
		OFString *stringValue;
		union {
			double d;
			uint64_t u;
		} d;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException exception];

		stringValue = [element stringValue];

		if ([stringValue isEqual: @"DISTANT_PAST"])
			_seconds = -INFINITY;
		else if ([stringValue isEqual: @"DISTANT_FUTURE"])
			_seconds = INFINITY;
		else {
			d.u = (uint64_t)[element hexadecimalValue];
			_seconds = d.d;
		}

		objc_autoreleasePoolPop(pool);
	} @catch (id e) {
		[self release];
		@throw e;
	}

382
383
384
385
386
387
388



389
390
391
392
393
394
395
396
397
398
399
400
401
402
403




404
405
406

407
408
409
410
411
412
413
		return OF_ORDERED_DESCENDING;

	return OF_ORDERED_SAME;
}

- (OFString*)description
{



	return [self dateStringWithFormat: @"%Y-%m-%dT%H:%M:%SZ"];
}

- (OFXMLElement*)XMLElementBySerializing
{
	void *pool = objc_autoreleasePoolPush();
	OFXMLElement *element;
	union {
		double d;
		uint64_t u;
	} d;

	element = [OFXMLElement elementWithName: [self className]
				      namespace: OF_SERIALIZATION_NS];





	d.d = _seconds;
	[element setStringValue:
	    [OFString stringWithFormat: @"%016" PRIx64, d.u]];


	[element retain];

	objc_autoreleasePoolPop(pool);

	return [element autorelease];
}







>
>
>
|














>
>
>
>
|
|
|
>







391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
		return OF_ORDERED_DESCENDING;

	return OF_ORDERED_SAME;
}

- (OFString*)description
{
	if (isinf(_seconds))
		return (_seconds > 0 ? @"Distant Future" : @"Distant Past");
	else
		return [self dateStringWithFormat: @"%Y-%m-%dT%H:%M:%SZ"];
}

- (OFXMLElement*)XMLElementBySerializing
{
	void *pool = objc_autoreleasePoolPush();
	OFXMLElement *element;
	union {
		double d;
		uint64_t u;
	} d;

	element = [OFXMLElement elementWithName: [self className]
				      namespace: OF_SERIALIZATION_NS];

	if (isinf(_seconds))
		[element setStringValue:
		    (_seconds > 0 ? @"DISTANT_FUTURE" : @"DISTANT_PAST")];
	else {
		d.d = _seconds;
		[element setStringValue:
		    [OFString stringWithFormat: @"%016" PRIx64, d.u]];
	}

	[element retain];

	objc_autoreleasePoolPop(pool);

	return [element autorelease];
}