rbatis / fastdate

fastdate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

offset overflow

git4unrealnondev opened this issue · comments

In datetime.rs the GLOBAL_OFFSET on my machine is set to -18000
When you call: Duration::from_secs(offset as u64)
It overflows to the max that u64 can store which causes program to overflow at line 55 causing the program to fault.
Duration::from_secs is set to the max that u64 can be.
Systemtime looks correct. Not sure why this is happening.
Related to fast_log issue that I had opened: rbatis/fast_log#12

Finished dev [unoptimized + debuginfo] target(s) in 0.26s
Running target/debug/beans
thread 'main' panicked at 'overflow when subtracting duration from instant', library/std/src/time.rs:600:9
stack backtrace:
0: rust_begin_unwind
at /rustc/29e4a9ee0253cd39e552a77f51f11f9a5f1c41e6/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /rustc/29e4a9ee0253cd39e552a77f51f11f9a5f1c41e6/library/core/src/panicking.rs:142:14
2: core::panicking::panic_display
at /rustc/29e4a9ee0253cd39e552a77f51f11f9a5f1c41e6/library/core/src/panicking.rs:72:5
3: core::panicking::panic_str
at /rustc/29e4a9ee0253cd39e552a77f51f11f9a5f1c41e6/library/core/src/panicking.rs:56:5
4: core::option::expect_failed
at /rustc/29e4a9ee0253cd39e552a77f51f11f9a5f1c41e6/library/core/src/option.rs:1874:5
5: core::option::Option::expect
at /rustc/29e4a9ee0253cd39e552a77f51f11f9a5f1c41e6/library/std/src/time.rs:600:9
6: <std::time::SystemTime as core::ops::arith::Subcore::time::Duration>::sub
at /rustc/29e4a9ee0253cd39e552a77f51f11f9a5f1c41e6/library/std/src/time.rs:600:9
7: fastdate::datetime::DateTime::now
at /home/linux/rust/fastdate/src/datetime.rs:55:24
8: beans::main
at ./src/main.rs:7:5
9: core::ops::function::FnOnce::call_once
at /rustc/29e4a9ee0253cd39e552a77f51f11f9a5f1c41e6/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.

Note looks like issue is with timezones and overflow.
I set timezone to beijing and it works perfectly fine.
I set timezone to chicago and it breaks with overflow.

Program needs support for all UTC timezone i think

commented

Yes, it's a bug. Has been fixed in a new version. Fastdate does not add time zone information to simplify the time. Instead, it resolves the time zone as it is parsed