-
Notifications
You must be signed in to change notification settings - Fork 594
Closed
Description
I'm trying to do an ls \.\pipe in nushell which causes a panic.
The ls \.\pipe lists the pipes on windows and according to powershell that date is 12/31/1600 7:00PM.
I have some details in my PR which sets and unsets the panic handler around chrono to handle the panic thrown from Chrono.
nushell/nushell#10558
Is there a way to make another interface/function which does not unwrap panic when called?
wrapping chrono in panic hooks to handle panic'ing unwraps on Jan 1, 1601 00:00 UTC and other reasons unknown is not ideal and I would love to have a better solution.
fn unix_time_to_local_date_time(secs: i64) -> Option<DateTime<Local>> {
let old_hook = std::panic::take_hook();
std::panic::set_hook(Box::new(|_info| {}));
let result = std::panic::catch_unwind(|| match Utc.timestamp_opt(secs, 0) {
LocalResult::Single(t) => Some(t.with_timezone(&Local)),
_ => None,
});
std::panic::set_hook(old_hook);
match result {
Ok(r) => r,
_ => None,
}
}
I'm not sure what chrono should tell me the timezone is in 1600, but I would prefer it not be via a panic.
Metadata
Metadata
Assignees
Labels
No labels