isbnlib/jsonb/block.rs
use serde::{Deserialize, Serialize};
use chrono;
#[derive(
Serialize,
Deserialize,
Debug,
Clone,
PartialEq,
)]
pub struct Block {
#[serde(rename(deserialize = "type"))]
pub value_type: String,
pub value: String
}
impl Block {
pub fn to_string(self) -> String {
self.value.to_string()
}
pub fn to_timestamp(self) -> chrono::NaiveDateTime {
chrono::NaiveDateTime::parse_from_str(&self.to_string(), "%Y-%m-%dT%H:%M:%S%.f").expect("Failed parse datetime")
}
}