Overview
Comment: | Add a few more methods to OFDate. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
2cc53cf92d74e2889f049544e2da0164 |
User & Date: | js on 2011-01-03 21:33:03 |
Other Links: | manifest | tags |
Context
2011-01-03
| ||
21:48 | Fix a typo in Makefile. check-in: 71df4f6b30 user: js tags: trunk | |
21:33 | Add a few more methods to OFDate. check-in: 2cc53cf92d user: js tags: trunk | |
2011-01-01
| ||
20:19 | Change license. check-in: da6b3d26cb user: js tags: trunk | |
Changes
Modified src/OFDate.h from [dcf8e442d6] to [49341feeb2].
︙ | |||
29 30 31 32 33 34 35 | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | - + - + | /** * \return A new, autoreleased OFDate with the current date and time */ + date; /** |
︙ | |||
73 74 75 76 77 78 79 | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | - + - + | * \return A date in the distant past */ + distantPast; /** * Initializes an already allocated OFDate with the specified date and time. * |
︙ | |||
209 210 211 212 213 214 215 216 217 218 219 220 221 222 | 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 235 236 237 238 239 240 241 242 | + + + + + + + + + + + + + + + + + + + + | /** * \param date Another date * \return The later date of the two dates */ - (OFDate*)laterDate: (OFDate*)date; /** * \return The seconds since 1970-01-01T00:00:00Z */ - (int64_t)timeIntervalSince1970; /** * \return The microseconds part of the seconds since 1970-01-01T00:00:00Z */ - (uint32_t)microsecondsOfTimeIntervalSince1970; /** * \return The seconds the date is after the receiver */ - (int64_t)timeIntervalSinceDate: (OFDate*)date; /** * \return The microseconds part of the seconds the date is after the receiver */ - (uint32_t)microsecondsOfTimeIntervalSinceDate: (OFDate*)date; /** * Returns a new date with the specified time interval added. * * \param sec The seconds after the date * \return A new, autoreleased OFDate */ - (OFDate*)dateByAddingTimeInterval: (int64_t)sec; |
︙ |
Modified src/OFDate.m from [5fce8dec4c] to [31a8bddc6c].
︙ | |||
223 224 225 226 227 228 229 | 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | - + | { self = [self init]; sec += sec_; usec += usec_; while (usec > 999999) { |
︙ | |||
359 360 361 362 363 364 365 | 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | - + | # ifdef OF_THREADS [mutex lock]; @try { # endif struct tm *tmp; |
︙ | |||
402 403 404 405 406 407 408 | 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | - + | # ifdef OF_THREADS [mutex lock]; @try { # endif struct tm *tmp; |
︙ | |||
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + | - (OFDate*)laterDate: (OFDate*)date { if ([self compare: date] == OF_ORDERED_ASCENDING) return [[date retain] autorelease]; return [[self retain] autorelease]; } - (int64_t)timeIntervalSince1970 { return sec; } - (uint32_t)microsecondsOfTimeIntervalSince1970 { return usec; } - (int64_t)timeIntervalSinceDate: (OFDate*)date { int64_t sec_ = sec - date->sec; int32_t usec_ = (int32_t)usec - date->usec; while (usec_ > 999999) { usec_ -= 1000000; sec_++; } while (usec < 0) { usec_ += 1000000; sec_--; } return sec_; } - (uint32_t)microsecondsOfTimeIntervalSinceDate: (OFDate*)date { int32_t usec_ = (int32_t)usec - date->usec; while (usec_ > 999999) usec_ -= 1000000; while (usec < 0) usec_ += 1000000; return usec_; } - (OFDate*)dateByAddingTimeInterval: (int64_t)sec_ { return [self dateByAddingTimeInterval: sec_ withMicroseconds: 0]; } - (OFDate*)dateByAddingTimeInterval: (int64_t)sec_ withMicroseconds: (uint32_t)usec_ { sec_ += sec; usec_ += usec; while (usec_ > 999999) { |