From f33ab30d13187f36b3ed03ceffda7781b9743308 Mon Sep 17 00:00:00 2001 From: RobbingDaHood <16130319+RobbingDaHood@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:52:54 +0100 Subject: [PATCH] #14123 Overwriting default date format to make it more consistent. --- crates/nu-command/src/date/utils.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/crates/nu-command/src/date/utils.rs b/crates/nu-command/src/date/utils.rs index 4616dc887b..ef6aaed48a 100644 --- a/crates/nu-command/src/date/utils.rs +++ b/crates/nu-command/src/date/utils.rs @@ -1,17 +1,27 @@ use chrono::{DateTime, FixedOffset, Local, LocalResult, TimeZone}; use nu_protocol::{record, ShellError, Span, Value}; +use std::collections::HashMap; pub(crate) fn parse_date_from_string( input: &str, span: Span, ) -> Result, Value> { - match dtparse::parse(input) { - Ok((native_dt, fixed_offset)) => { - let offset = match fixed_offset { + match dtparse::Parser::default().parse( + input, + Some(true), + Some(true), + false, + false, + None, + false, + &HashMap::new(), + ) { + Ok(result) => { + let offset = match result.1 { Some(offset) => offset, None => *(Local::now().offset()), }; - match offset.from_local_datetime(&native_dt) { + match offset.from_local_datetime(&result.0) { LocalResult::Single(d) => Ok(d), LocalResult::Ambiguous(d, _) => Ok(d), LocalResult::None => Err(Value::error(