1
0

Write docs; Improve Time Display

This commit is contained in:
Jeff 2023-08-24 00:26:37 -04:00
parent 19249c0e50
commit 2744ecf387
3 changed files with 17 additions and 14 deletions

View File

@ -242,10 +242,13 @@ impl Tool for Select {
identifier: "select",
description: "Extract one or more values based on their key.",
group: "collections",
inputs: vec![ValueType::ListExact(vec![
ValueType::Table,
ValueType::ListOf(Box::new(ValueType::String)),
])],
inputs: vec![
ValueType::ListExact(vec![ValueType::Table, ValueType::String]),
ValueType::ListExact(vec![
ValueType::Table,
ValueType::ListOf(Box::new(ValueType::String)),
]),
],
}
}

View File

@ -1,6 +1,6 @@
use std::{
fmt::{self, Display, Formatter},
time::{Instant, SystemTime, UNIX_EPOCH},
time::{Instant, SystemTime},
};
use chrono::{DateTime, FixedOffset, Local as LocalTime, NaiveDateTime};
@ -50,7 +50,7 @@ impl Time {
),
};
date_time.to_string()
date_time.to_rfc2822()
}
}
@ -80,9 +80,6 @@ impl<'de> Deserialize<'de> for Time {
impl From<SystemTime> for Time {
fn from(value: SystemTime) -> Self {
let timestamp = value.duration_since(UNIX_EPOCH).unwrap().as_micros();
let naive = NaiveDateTime::from_timestamp_micros(timestamp as i64).unwrap();
Time::Utc(naive)
Time::Local(value.into())
}
}

View File

@ -6,7 +6,10 @@ use std::{
use crate::{value::Value, Error, Result, Table, TOOL_LIST};
/// A context that stores its mappings in hash maps.
/// A collection dust variables comprised of key-value pairs.
///
/// The inner value is a BTreeMap in order to allow VariableMap instances to be sorted and compared
/// to one another.
#[derive(Clone, Debug, PartialEq, PartialOrd, Ord, Eq, Serialize, Deserialize)]
pub struct VariableMap {
variables: BTreeMap<String, Value>,
@ -95,8 +98,8 @@ impl VariableMap {
pub fn set_value(&mut self, identifier: &str, value: Value) -> Result<()> {
let split = identifier.split_once('.');
if let Some((map_name, next_identifier)) = split {
let get_value = self.variables.get_mut(map_name);
if let Some((identifier, next_identifier)) = split {
let get_value = self.variables.get_mut(identifier);
if let Some(found_value) = get_value {
if let Value::List(list) = found_value {
@ -130,7 +133,7 @@ impl VariableMap {
new_map.set_value(next_identifier, value)?;
self.variables
.insert(map_name.to_string(), Value::Map(new_map));
.insert(identifier.to_string(), Value::Map(new_map));
Ok(())
}