enable ls to output datetime in local time vs utc (#5141)

* enable `ls` to output datetime in local time vs utc

* clippy
This commit is contained in:
Darren Schroeder 2022-04-09 11:39:41 -05:00 committed by GitHub
parent 14066ccc30
commit 791e8a0e59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
use crate::DirBuilder; use crate::DirBuilder;
use crate::DirInfo; use crate::DirInfo;
use chrono::{DateTime, Utc}; use chrono::{DateTime, Local};
use nu_engine::env::current_dir; use nu_engine::env::current_dir;
use nu_engine::CallExt; use nu_engine::CallExt;
use nu_protocol::ast::Call; use nu_protocol::ast::Call;
@ -477,9 +477,9 @@ pub(crate) fn dir_entry_dict(
if long { if long {
cols.push("created".to_string()); cols.push("created".to_string());
if let Ok(c) = md.created() { if let Ok(c) = md.created() {
let utc: DateTime<Utc> = c.into(); let utc: DateTime<Local> = c.into();
vals.push(Value::Date { vals.push(Value::Date {
val: utc.into(), val: utc.with_timezone(utc.offset()),
span, span,
}); });
} else { } else {
@ -488,9 +488,9 @@ pub(crate) fn dir_entry_dict(
cols.push("accessed".to_string()); cols.push("accessed".to_string());
if let Ok(a) = md.accessed() { if let Ok(a) = md.accessed() {
let utc: DateTime<Utc> = a.into(); let utc: DateTime<Local> = a.into();
vals.push(Value::Date { vals.push(Value::Date {
val: utc.into(), val: utc.with_timezone(utc.offset()),
span, span,
}); });
} else { } else {
@ -500,9 +500,9 @@ pub(crate) fn dir_entry_dict(
cols.push("modified".to_string()); cols.push("modified".to_string());
if let Ok(m) = md.modified() { if let Ok(m) = md.modified() {
let utc: DateTime<Utc> = m.into(); let utc: DateTime<Local> = m.into();
vals.push(Value::Date { vals.push(Value::Date {
val: utc.into(), val: utc.with_timezone(utc.offset()),
span, span,
}); });
} else { } else {