Skip to content
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

Time Error #11

Open
Nathanwoodburn opened this issue Nov 14, 2022 · 3 comments
Open

Time Error #11

Nathanwoodburn opened this issue Nov 14, 2022 · 3 comments

Comments

@Nathanwoodburn
Copy link

I'm getting time error. It has been happening since I installed the wrapper.
image

@Cldfire
Copy link
Owner

Cldfire commented Nov 24, 2022

Interesting, are you using one of the compiled binaries available for download from the releases page on this GitHub repo or did you compile the binary yourself? And what OS / OS version are you running it on?

@Nathanwoodburn
Copy link
Author

I compiled it on Ubuntu Linux.

@Cldfire
Copy link
Owner

Cldfire commented Nov 24, 2022

Gotcha. So there's a .cargo/config file that's supposed to set a compilation flag to stop that from happening:

[build]
# See https://github.com/time-rs/time/issues/293#issuecomment-1005002386. The
# unsoundness here is not in the `time` library, but in the Rust stdlib, and as
# such it needs to be fixed there.
rustflags = "--cfg unsound_local_offset"

It's possible that either cargo isn't picking up the compilation flag when you're compiling it locally (which I'm not sure how to direct you to debug) or that there's an error determining the local offset for some other reason. You might want to try downloading the last Linux binary from https://github.com/Cldfire/mc-server-wrapper/releases and seeing if you get time in the logs with that.

The other thing you could try is editing this code:

let formatted_time_now = || -> Option<String> {
// TODO: log errors here somehow
time::OffsetDateTime::now_local()
.ok()
.and_then(|datetime| datetime.format(&CONSOLE_TIMESTAMP_FORMAT).ok())
};
let record = format!(
"[{}] [{}, {}]: {}",
formatted_time_now().unwrap_or_else(|| String::from("time error")),
record.target(),
record.level(),
record.args()
);

to this:

let record = format!(
    "[{}] [{}, {}]: {}",
    time::OffsetDateTime::now_utc()
        .format(&CONSOLE_TIMESTAMP_FORMAT)
        .unwrap_or_else(|_| String::from("time error")),
    record.target(),
    record.level(),
    record.args()
);

That'll get you UTC time with no local offset, which is (seemingly) infallible. If you do that you probably want to mess with the time formatting above there and go from 12h -> 24h time too (ideally time formatting would be configurable in the config at some point).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants