Differences From Artifact [f357555e03]:
- File src/OFDate.m — part of check-in [3b97fc3cd9] at 2014-01-04 00:24:08 on branch trunk — Update copyright. (user: js, size: 12624) [annotate] [blame] [check-ins using]
To Artifact [8e1ed139e9]:
- File
src/OFDate.m
— part of check-in
[dc31ce3d34]
at
2014-01-16 23:09:11
on branch trunk
— Add of_time_interval_t.
This is used instead for time intervals now instead of doubles. (user: js, size: 12756) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
159 160 161 162 163 164 165 | #endif + (instancetype)date { return [[[self alloc] init] autorelease]; } | | | | 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | #endif + (instancetype)date { return [[[self alloc] init] autorelease]; } + (instancetype)dateWithTimeIntervalSince1970: (of_time_interval_t)seconds { return [[[self alloc] initWithTimeIntervalSince1970: seconds] autorelease]; } + (instancetype)dateWithTimeIntervalSinceNow: (of_time_interval_t)seconds { return [[[self alloc] initWithTimeIntervalSinceNow: seconds] autorelease]; } + (instancetype)dateWithDateString: (OFString*)string format: (OFString*)format |
︙ | ︙ | |||
206 207 208 209 210 211 212 | struct timeval t; self = [super init]; OF_ENSURE(gettimeofday(&t, NULL) == 0); _seconds = t.tv_sec; | | | | | 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 | struct timeval t; self = [super init]; OF_ENSURE(gettimeofday(&t, NULL) == 0); _seconds = t.tv_sec; _seconds += (of_time_interval_t)t.tv_usec / 1000000; return self; } - initWithTimeIntervalSince1970: (of_time_interval_t)seconds { self = [super init]; _seconds = seconds; return self; } - initWithTimeIntervalSinceNow: (of_time_interval_t)seconds { self = [self init]; _seconds += seconds; return self; } |
︙ | ︙ | |||
604 605 606 607 608 609 610 | if ([self compare: otherDate] == OF_ORDERED_ASCENDING) return [[otherDate retain] autorelease]; return [[self retain] autorelease]; } | | | | | | | | 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 | if ([self compare: otherDate] == OF_ORDERED_ASCENDING) return [[otherDate retain] autorelease]; return [[self retain] autorelease]; } - (of_time_interval_t)timeIntervalSince1970 { return _seconds; } - (of_time_interval_t)timeIntervalSinceDate: (OFDate*)otherDate { return _seconds - otherDate->_seconds; } - (of_time_interval_t)timeIntervalSinceNow { struct timeval t; of_time_interval_t seconds; OF_ENSURE(!gettimeofday(&t, NULL)); seconds = t.tv_sec; seconds += (of_time_interval_t)t.tv_usec / 1000000; return _seconds - seconds; } - (OFDate*)dateByAddingTimeInterval: (of_time_interval_t)seconds { return [OFDate dateWithTimeIntervalSince1970: _seconds + seconds]; } @end |