-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix timestamp_local() #44
base: master
Are you sure you want to change the base?
Conversation
Strangely I get an indeterminate offset error on my local machine as well. I will have to look into this more (also thank you for the PR 😄 ) |
The time displayed now is actually UTC, which should be a bug. |
remove unused time features This is fine to merge right now. I want to look at #44 more closely because it addresses a very serious bug However, I'm not sure the solution works because I get an error on my local machine and on Github Actions :(
I asked why this is failing in time-rs/time#455 and got this response:
So unfortunately it appears we are either: |
I think we could override the This would allow workaround the nasty soundness issues of the underlying system methods. Then we could just have UTC for time values (by default). Technically requiring an explicit offset is a breaking change. However it isn't really breaking because the code relying on system offset was never sound before. I am not sure if the previous impl was silently unsound or always gave an error. I will have to go back and check...... |
after some dig, the Maybe we can switch depency from |
Hello, regardless of the fact that Code: fn main() {
println!(
"Into::<time::OffsetDateTime>::into(std::time::SystemTime::now()): {:?}",
Into::<time::OffsetDateTime>::into(std::time::SystemTime::now())
);
println!(
"time::OffsetDateTime::now_utc(): {:?}",
time::OffsetDateTime::now_utc()
);
println!(
"time::OffsetDateTime::now_local(): {:?}",
time::OffsetDateTime::now_local().unwrap()
);
} Output:
So II think the method used so far to handle local time doesn't work :) |
I just had an idea on how to fix the default time formatting without breaking backwards compatibility. The new default formatting will include an explicit UTC timezone specifier, so it will be clear it's not in local time. This will avoid the unsafety of getting the localtime when multiple threads are involved. |
As discussed in PR slog-rs#44, the 'time' crate fails timezine detection in the prsesense of multiple threads, because the underlying POSIX function localtime_r is not thread safe (at least not on Linux). In order to avoid these thread-safety issues, we use the chrono crate. It avoids system libraries and reimplements timezone detection from scratch. (Thanks to @yaozongyou for pointing this out) TODO: Maybe we should switch to chono entirely. It seems to be a fairly complete replacement. What are the advantages & disadvantages?
cf #43