Add string to datetime to str plugin (#1381)

* Add string to datetime to str plugin

* Test string to date/time conversion
This commit is contained in:
Corvus Corax
2020-02-13 09:47:04 -06:00
committed by GitHub
parent 84927d52b5
commit 0961da406d
6 changed files with 70 additions and 20 deletions

View File

@ -15,6 +15,7 @@ use crate::value::primitive::Primitive;
use crate::value::range::{Range, RangeInclusion};
use crate::{ColumnPath, PathMember};
use bigdecimal::BigDecimal;
use chrono::{DateTime, Utc};
use indexmap::IndexMap;
use nu_errors::ShellError;
use nu_source::{AnchorLocation, HasSpan, Span, Spanned, Tag};
@ -201,6 +202,10 @@ impl UntaggedValue {
UntaggedValue::Primitive(Primitive::Date(s.into()))
}
pub fn date(d: impl Into<DateTime<Utc>>) -> UntaggedValue {
UntaggedValue::Primitive(Primitive::Date(d.into()))
}
/// Helper for creating the Nothing value
pub fn nothing() -> UntaggedValue {
UntaggedValue::Primitive(Primitive::Nothing)