Struct foxbox_taxonomy::values::TimeStamp [] [src]

pub struct TimeStamp(_);

An absolute time and date.

JSON

Represented by a string. This data structure accepts string formatted as RFC 3339 such as "2014-11-28T21:45:59.324310806+09:00".

extern crate chrono;
extern crate foxbox_taxonomy;

use foxbox_taxonomy::values::*;
use foxbox_taxonomy::parse::*;
use foxbox_taxonomy::serialize::*;
use chrono::Datelike;


let parsed = TimeStamp::from_str("\"2014-11-28T21:45:59.324310806+09:00\"").unwrap();
let date_time = parsed.as_datetime().clone();
assert_eq!(date_time.year(), 2014);
assert_eq!(date_time.month(), 11);
assert_eq!(date_time.day(), 28);


let serialized: JSON = parsed.to_json(&mut MultiPart::new());
assert!(serialized.as_string().unwrap().starts_with("2014-11-28"));

Methods

impl TimeStamp

fn from_datetime(datetime: DateTime<UTC>) -> Self

fn as_datetime(&self) -> &DateTime<UTC>

fn from_s(s: i64) -> Self

Trait Implementations

impl Parser<TimeStamp> for TimeStamp

fn description() -> String

fn parse(path: Path, source: &mut JSON) -> Result<Self, ParseError>

fn from_str(source: &str) -> Result<T, ParseError>

fn take(path: Path, source: &mut JSON, field_name: &str) -> Result<T, ParseError>

fn take_opt(path: Path, source: &mut JSON, field_name: &str) -> Option<Result<T, ParseError>>

fn take_vec_opt(path: Path, source: &mut JSON, field_name: &str) -> Option<Result<Vec<T>, ParseError>>

fn take_vec(path: Path, source: &mut JSON, field_name: &str) -> Result<Vec<T>, ParseError>

impl ToJSON for TimeStamp

fn to_json(&self, parts: &mut BinaryParts) -> JSON

impl Into<DateTime<UTC>> for TimeStamp

fn into(self) -> DateTime<UTC>

impl Into<DateTime<Local>> for TimeStamp

fn into(self) -> DateTime<Local>

impl<T> From<DateTime<T>> for TimeStamp where T: TimeZone

fn from(date: DateTime<T>) -> Self

impl Serialize for TimeStamp

fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error> where S: Serializer

impl Deserialize for TimeStamp

fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error> where D: Deserializer

Derived Implementations

impl Ord for TimeStamp

fn cmp(&self, __arg_0: &TimeStamp) -> Ordering

impl Eq for TimeStamp

impl PartialOrd for TimeStamp

fn partial_cmp(&self, __arg_0: &TimeStamp) -> Option<Ordering>

fn lt(&self, __arg_0: &TimeStamp) -> bool

fn le(&self, __arg_0: &TimeStamp) -> bool

fn gt(&self, __arg_0: &TimeStamp) -> bool

fn ge(&self, __arg_0: &TimeStamp) -> bool

impl PartialEq for TimeStamp

fn eq(&self, __arg_0: &TimeStamp) -> bool

fn ne(&self, __arg_0: &TimeStamp) -> bool

impl Clone for TimeStamp

fn clone(&self) -> TimeStamp

1.0.0fn clone_from(&mut self, source: &Self)

impl Debug for TimeStamp

fn fmt(&self, __arg_0: &mut Formatter) -> Result