pub fn date(value: Value, mut args: HashMap<String, Value>) -> Result<Value> {
    let format = match args.remove("format") {
        Some(val) => try_get_value!("date", "format", String, val),
        None => "%Y-%m-%d".to_string(),
    };

    let formatted = match value {
        Value::Number(n) => match n.as_i64() {
            Some(i) => NaiveDateTime::from_timestamp(i, 0).format(&format),
            None => bail!("Filter `date` was invoked on a float: {}", n),
        },
        Value::String(s) => {
            if s.contains('T') {
                match s.parse::<DateTime<FixedOffset>>() {
                    Ok(val) => val.format(&format),
                    Err(_) => match s.parse::<NaiveDateTime>() {
                        Ok(val) => val.format(&format),
                        Err(_) => {
                            bail!("Error parsing `{:?}` as rfc3339 date or naive datetime", s)
                        }
                    },
                }
            } else {
                match NaiveDate::parse_from_str(&s, "%Y-%m-%d") {
                    Ok(val) => DateTime::<Utc>::from_utc(val.and_hms(0, 0, 0), Utc).format(&format),
                    Err(_) => bail!("Error parsing `{:?}` as YYYY-MM-DD date", s),
                }
            }
        }
        _ => bail!(
            "Filter `date` received an incorrect type for arg `value`: \
             got `{:?}` but expected i64|u64|String",
            value
        ),
    };

    Ok(to_value(&formatted.to_string())?)
}
/// Returns a formatted time according to the given `format` argument.
/// `format` defaults to the ISO 8601 `YYYY-MM-DD` format.
///
/// Input can be an i64 timestamp (seconds since epoch) or an RFC3339 string
/// (default serialization format for `chrono::DateTime`).
///
/// a full reference for the time formatting syntax is available
/// on [chrono docs](https://lifthrasiir.github.io/rust-chrono/chrono/format/strftime/index.html)
Returns a formatted time according to the given `format` argument.
`format` defaults to the ISO 8601 `YYYY-MM-DD` format.

Input can be an i64 timestamp (seconds since epoch) or an RFC3339 string
(default serialization format for `chrono::DateTime`).

a full reference for the time formatting syntax is available
on [chrono docs]
Returns a formatted time according to the given ` format ` argument . ` format ` defaults to the ISO 8601 ` YYYY - MM - DD ` format . Input can be an i64 timestamp ( seconds since epoch ) or an RFC3339 string ( default serialization format for ` chrono :: DateTime ` ) . a full reference for the time formatting syntax is available on [ chrono docs ]
pub fn date(value: Value, mut args: HashMap<String, Value>) -> Result<Value> {
    let format = match args.remove("format") {
        Some(val) => try_get_value!("date", "format", String, val),
        None => "%Y-%m-%d".to_string(),
    };
    let formatted = match value {
        Value::Number(n) => match n.as_i64() {
            Some(i) => NaiveDateTime::from_timestamp(i, 0).format(&format),
            None => bail!("Filter `date` was invoked on a float: {}", n),
        },
        Value::String(s) => {
            if s.contains('T') {
                match s.parse::<DateTime<FixedOffset>>() {
                    Ok(val) => val.format(&format),
                    Err(_) => match s.parse::<NaiveDateTime>() {
                        Ok(val) => val.format(&format),
                        Err(_) => {
                            bail!("Error parsing `{:?}` as rfc3339 date or naive datetime", s)
                        }
                    },
                }
            } else {
                match NaiveDate::parse_from_str(&s, "%Y-%m-%d") {
                    Ok(val) => DateTime::<Utc>::from_utc(val.and_hms(0, 0, 0), Utc).format(&format),
                    Err(_) => bail!("Error parsing `{:?}` as YYYY-MM-DD date", s),
                }
            }
        }
        _ => bail!(
            "Filter `date` received an incorrect type for arg `value`: \
             got `{:?}` but expected i64|u64|String",
            value
        ),
    };
    Ok(to_value(&formatted.to_string())?)
}
pub fn date ( value : Value , mut args : HashMap < String , Value > ) -> Result < Value > { let format = match args . remove ( " " ) { Some ( val ) => try_get_value ! ( " " " " String val ) , None => " " . to_string ( ) , } ; let formatted = match value { Value :: Number ( n ) => match n . as_i64 ( ) { Some ( i ) => NaiveDateTime :: from_timestamp ( i , 0 ) . format ( & format ) , None => bail ! ( " " n ) , } , Value :: String ( s ) => { if s . contains ( 'T' ) { match s . parse :: < DateTime < FixedOffset > > ( ) { Ok ( val ) => val . format ( & format ) , Err ( _ ) => match s . parse :: < NaiveDateTime > ( ) { Ok ( val ) => val . format ( & format ) , Err ( _ ) => { bail ! ( " " s ) } } , } } else { match NaiveDate :: parse_from_str ( & s , " " ) { Ok ( val ) => DateTime :: < Utc > :: from_utc ( val . and_hms ( 0 , 0 , 0 ) , Utc ) . format ( & format ) , Err ( _ ) => bail ! ( " " s ) , } } } _ => bail ! ( " \
 " value ) , } ; Ok ( to_value ( & formatted . to_string ( ) ) ? ) }
Returns a formatted time according to the given `format` argument.
Returns a formatted time according to the given ` format ` argument .
value
Value
args
HashMap<String, Value>
value
Value
args
HashMap<String, Value>