Overview
Comment: | Make OFDate a proper class cluster |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
3865cc56952edc9d8357767b81b460b7 |
User & Date: | js on 2023-08-08 21:06:58 |
Other Links: | manifest | tags |
Context
2023-08-08
| ||
21:16 | Make OFColor a proper class cluster check-in: ea9b62035b user: js tags: trunk | |
21:06 | Make OFDate a proper class cluster check-in: 3865cc5695 user: js tags: trunk | |
15:32 | A few minor cleanups check-in: a6f520157a user: js tags: trunk | |
Changes
Modified src/OFDate.h from [5d6447d0f7] to [0270f8788a].
︙ | ︙ | |||
22 23 24 25 26 27 28 | @class OFConstantString; /** * @class OFDate OFDate.h ObjFW/OFDate.h * * @brief A class for storing, accessing and comparing dates. */ | < < < < < < < | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | @class OFConstantString; /** * @class OFDate OFDate.h ObjFW/OFDate.h * * @brief A class for storing, accessing and comparing dates. */ @interface OFDate: OFObject <OFCopying, OFComparing, OFMessagePackRepresentation> #ifdef OF_HAVE_CLASS_PROPERTIES @property (class, readonly, nonatomic) OFDate *distantFuture; @property (class, readonly, nonatomic) OFDate *distantPast; #endif /** * @brief The microsecond of the date. |
︙ | ︙ |
Modified src/OFDate.m from [abe4f98453] to [93145b86e5].
︙ | ︙ | |||
42 43 44 45 46 47 48 | #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 | | < | > > > | | 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 OFDatePlaceholder: OFDate @end @interface OFConcreteDate: OFDate { OFTimeInterval _seconds; } @end @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 | value & ~(UINT64_C(4) << 60)); if (ret != nil) return ret; } #endif | > | > > > > > > > > > > > > > > > > | 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] 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 | #endif #if defined(OF_OBJFW_RUNTIME) && UINTPTR_MAX == UINT64_MAX dateTag = objc_registerTaggedPointerClass([OFTaggedPointerDate class]); #endif } | < < < < < | 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)alloc { if (self == [OFDate class]) return (id)&placeholder; return [super alloc]; } |
︙ | ︙ | |||
424 425 426 427 428 429 430 | - (instancetype)init { return [self initWithTimeIntervalSince1970: now()]; } - (instancetype)initWithTimeIntervalSince1970: (OFTimeInterval)seconds { | > > > > | > | | > | > | | 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 release]; @throw e; } abort(); } return [super init]; } - (instancetype)initWithTimeIntervalSinceNow: (OFTimeInterval)seconds { return [self initWithTimeIntervalSince1970: now() + seconds]; } |
︙ | ︙ | |||
829 830 831 832 833 834 835 | return otherDate; return self; } - (OFTimeInterval)timeIntervalSince1970 { | | | 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 | return otherDate; return self; } - (OFTimeInterval)timeIntervalSince1970 { OF_UNRECOGNIZED_SELECTOR } - (OFTimeInterval)timeIntervalSinceDate: (OFDate *)otherDate { return self.timeIntervalSince1970 - otherDate.timeIntervalSince1970; } |
︙ | ︙ |