Commit 1e2b688
committed
Issue #25155: Add _PyTime_AsTimevalTime_t() function
On Windows, the tv_sec field of the timeval structure has the type C long,
whereas it has the type C time_t on all other platforms. A C long has a size of
32 bits (signed inter, 1 bit for the sign, 31 bits for the value) which is not
enough to store an Epoch timestamp after the year 2038.
Add the _PyTime_AsTimevalTime_t() function written for datetime.datetime.now():
convert a _PyTime_t timestamp to a (secs, us) tuple where secs type is time_t.
It allows to support dates after the year 2038 on Windows.
Enhance also _PyTime_AsTimeval_impl() to detect overflow on the number of
seconds when rounding the number of microseconds.1 parent 1bd0b54 commit 1e2b688
3 files changed
Lines changed: 77 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
123 | 135 | | |
124 | 136 | | |
125 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4117 | 4117 | | |
4118 | 4118 | | |
4119 | 4119 | | |
4120 | | - | |
| 4120 | + | |
| 4121 | + | |
4121 | 4122 | | |
4122 | | - | |
| 4123 | + | |
4123 | 4124 | | |
4124 | | - | |
| 4125 | + | |
4125 | 4126 | | |
4126 | | - | |
| 4127 | + | |
4127 | 4128 | | |
4128 | 4129 | | |
4129 | 4130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
420 | | - | |
421 | | - | |
| 420 | + | |
| 421 | + | |
422 | 422 | | |
423 | 423 | | |
424 | | - | |
425 | 424 | | |
| 425 | + | |
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
429 | 429 | | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | 430 | | |
439 | 431 | | |
440 | 432 | | |
441 | | - | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
442 | 437 | | |
443 | 438 | | |
444 | 439 | | |
445 | | - | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
446 | 444 | | |
447 | | - | |
448 | 445 | | |
449 | | - | |
450 | 446 | | |
451 | | - | |
452 | | - | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
453 | 450 | | |
454 | 451 | | |
455 | 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 | + | |
456 | 478 | | |
457 | 479 | | |
458 | 480 | | |
459 | | - | |
| 481 | + | |
460 | 482 | | |
461 | 483 | | |
462 | 484 | | |
463 | 485 | | |
464 | 486 | | |
465 | | - | |
| 487 | + | |
466 | 488 | | |
467 | 489 | | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
468 | 509 | | |
469 | 510 | | |
470 | 511 | | |
| |||
0 commit comments