ObjFW  Diff

Differences From Artifact [abe4f98453]:

To Artifact [93145b86e5]:


42
43
44
45
46
47
48
49

50
51
52
53




54
55
56

57
58
59
60
61
62
63
42
43
44
45
46
47
48

49

50
51

52
53
54
55
56
57

58
59
60
61
62
63
64
65







-
+
-


-
+
+
+
+


-
+







#import "OFOutOfRangeException.h"

#if defined(OF_AMIGAOS_M68K) || defined(OF_MINT)
/* amiga-gcc and freemint-gcc do not have trunc() */
# define trunc(x) ((int64_t)(x))
#endif

@interface OFDate ()
@interface OFDatePlaceholder: OFDate
+ (instancetype)of_alloc;
@end

@interface OFDateSingleton: OFDate
@interface OFConcreteDate: OFDate
{
	OFTimeInterval _seconds;
}
@end

@interface OFDatePlaceholder: OFDateSingleton
@interface OFDateSingleton: OFConcreteDate
@end

#if defined(OF_OBJFW_RUNTIME) && UINTPTR_MAX == UINT64_MAX
@interface OFTaggedPointerDate: OFDateSingleton
@end
#endif

309
310
311
312
313
314
315

316

317
318
319
320
321
















322
323
324
325
326
327
328
311
312
313
314
315
316
317
318

319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347







+
-
+





+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







		    value & ~(UINT64_C(4) << 60));

		if (ret != nil)
			return ret;
	}
#endif

	return (id)[[OFConcreteDate alloc]
	return (id)[[OFDate of_alloc] initWithTimeIntervalSince1970: seconds];
	    initWithTimeIntervalSince1970: seconds];
}
#ifdef __clang__
# pragma clang diagnostic pop
#endif
@end

@implementation OFConcreteDate
- (instancetype)initWithTimeIntervalSince1970: (OFTimeInterval)seconds
{
	self = [super initWithTimeIntervalSince1970: seconds];

	_seconds = seconds;

	return self;
}

- (OFTimeInterval)timeIntervalSince1970
{
	return _seconds;
}
@end

#if defined(OF_OBJFW_RUNTIME) && UINTPTR_MAX == UINT64_MAX
@implementation OFTaggedPointerDate
- (OFTimeInterval)timeIntervalSince1970
{
	uint64_t value = (uint64_t)object_getTaggedPointerValue(self);

359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384





385
386
387
388
389
390
391







-
-
-
-
-







#endif

#if defined(OF_OBJFW_RUNTIME) && UINTPTR_MAX == UINT64_MAX
	dateTag = objc_registerTaggedPointerClass([OFTaggedPointerDate class]);
#endif
}

+ (instancetype)of_alloc
{
	return [super alloc];
}

+ (instancetype)alloc
{
	if (self == [OFDate class])
		return (id)&placeholder;

	return [super alloc];
}
424
425
426
427
428
429
430




431
432
433
434
435








436
437
438
439
440
441
442
438
439
440
441
442
443
444
445
446
447
448





449
450
451
452
453
454
455
456
457
458
459
460
461
462
463







+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+







- (instancetype)init
{
	return [self initWithTimeIntervalSince1970: now()];
}

- (instancetype)initWithTimeIntervalSince1970: (OFTimeInterval)seconds
{
	if ([self isMemberOfClass: [OFDate class]]) {
		@try {
			[self doesNotRecognizeSelector: _cmd];
		} @catch (id e) {
	self = [super init];

	_seconds = seconds;

	return self;
			[self release];
			@throw e;
		}

		abort();
	}

	return [super init];
}

- (instancetype)initWithTimeIntervalSinceNow: (OFTimeInterval)seconds
{
	return [self initWithTimeIntervalSince1970: now() + seconds];
}

829
830
831
832
833
834
835
836

837
838
839
840
841
842
843
850
851
852
853
854
855
856

857
858
859
860
861
862
863
864







-
+







		return otherDate;

	return self;
}

- (OFTimeInterval)timeIntervalSince1970
{
	return _seconds;
	OF_UNRECOGNIZED_SELECTOR
}

- (OFTimeInterval)timeIntervalSinceDate: (OFDate *)otherDate
{
	return self.timeIntervalSince1970 - otherDate.timeIntervalSince1970;
}