tailhook / humantime

A parser and formatter for std::time::{SystemTime, Duration}
Apache License 2.0
285 stars 36 forks source link

2 tests are failing on 32bit platforms #2

Closed ignatenkobrain closed 6 years ago

ignatenkobrain commented 6 years ago
failures:
---- date::test::upper_bound stdout ----
    thread 'date::test::upper_bound' panicked at 'overflow when adding duration to time', libcore/option.rs:891:5
---- date::test::random_wide_range stdout ----
    thread 'date::test::random_wide_range' panicked at 'overflow when adding duration to time', libcore/option.rs:891:5
failures:
    date::test::random_wide_range
    date::test::upper_bound
test result: FAILED. 24 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out
cuviper commented 6 years ago

These are both Year 2038 problems. upper_bound is testing "9999-12-31T23:59:59Z", and random_wide_range is trying to generate times anywhere from the epoch 0 to that same endpoint.

tailhook commented 6 years ago

Okay, I've fixed tests by conditional compilation in 02d0e7d, as well as actual runtime panic on parsing large timestamps. The problem is that because the implementation of SystemTime is platform specific the limits may be different between platforms. And there is neither SystemTime::MAX nor SystemTime::checked_add which could help.

I've added a check that ensures that 32bit platform has 2038-year problem. But no I realized that wasm32 does not have this problem. An I should also check at least windows somehow.

Any thoughts?

cuviper commented 6 years ago

It's definitely messy. Here's what I found for SystemTime implementations:

tailhook commented 6 years ago

@cuviper please take a look at PR #3 . Implementation is mostly as in your comment except I believe that emscripten uses 32bit time_t too, that's only wasm32-unknown-unknown which uses full Duration.

tailhook commented 6 years ago

I think the issue is fixed. Please reopen if it's not.