bug in DateTimeStrFormat? #5631

issue Diapolo opened this issue on January 9, 2015
  1. Diapolo commented at 4:08 PM on January 9, 2015: none

    Who can explain it to me?

    Using DateTimeStrFormat("%Y-%m-%d %H:%M:%S", NUMBER)

    0x7FFFFFFFFFFFFFFF (9223372036854775807, maximum of int64_t) prints: 1969-12-31 23:59:59

    0x7FFFFFFFFFFFFFFF + 1 prints: 1970-01-01 00:00:00

    0xFFFFFFFFFFFFFFFF prints: 1969-12-31 23:59:59

    0 prints: 1970-01-01 00:00:00

  2. jonasschnelli commented at 4:46 PM on January 9, 2015: contributor
  3. Diapolo commented at 10:40 PM on January 9, 2015: none

    @jonasschnelli Are you sure that we suffer from that problem or is it something different here?

  4. sipa commented at 11:22 PM on January 9, 2015: member

    When the int64 0x7FFFFFFFFFFFFFFF is converted to a 32-bit time_t, it becomes 0xFFFFFFFF, which is -1. so you're really passing -1. 1 second before Epoch is 1969-12-31 23:59:59.

  5. Diapolo commented at 11:25 PM on January 9, 2015: none

    I really had the impression Bitcoin Core would be using real 64 bit values for time or is that a Boost limitation currently? My compiler is a x64 one (MinGW).

  6. laanwj commented at 9:14 AM on January 10, 2015: member

    We use int64_t for time internally, but that doesn't mean that e.g. the OS or dependency libraries for time formatting and parsing can handle the full range.

    E.g. boost::posix_time::from_time_t in this case takes a std::time_t, as it says on the tin. So in theory if your build environment has a 64-bit std::time_t (this is the case here), it should handle 0x7FFFFFFFFFFFFFFFLL.

    But I get the same result. So this may be a bug in boost, or somewhere else down the line.

  7. laanwj added the label Bug on Jan 10, 2015
  8. laanwj added the label Priority Low on Jan 10, 2015
  9. laanwj added the label Upstream on Jan 10, 2015
  10. paveljanik commented at 12:17 PM on February 6, 2015: contributor
  11. jonasschnelli commented at 12:57 PM on February 6, 2015: contributor

    Huu.. opened 4 years ago, last edit 3 years ago.

  12. fanquake commented at 12:42 PM on May 18, 2017: member

    From what I can tell, this has been fixed in date_time (Boost ticket 4543), and the changes have been merged into Boost as part of 1.64.0, which we are now using.

  13. laanwj removed the label Priority Low on Dec 6, 2017
  14. meshcollider closed this on Mar 9, 2018

  15. fanquake commented at 8:30 AM on March 9, 2018: member

    @meshcollider I don’t think this will actually be fixed until Boost 1.67.0?

  16. fanquake reopened this on Mar 9, 2018

  17. ken2812221 commented at 3:37 AM on September 10, 2018: contributor

    Can this be closed? We're not using DateTimeStrFormat after #12973

  18. fanquake closed this on Sep 10, 2018

  19. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-17 00:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me