pub struct Date {
pub year: u16,
pub month: u8,
pub day: u8,
pub hour: u8,
pub minute: u8,
pub second: u8,
}Expand description
§Date Structure
§Description
Convenience Date structure to model like a Javascript Date object.
§Usage
The methods you have access to:
Date::new: Create a new DateDate::new_full: Creates a full DateDate::from_time: Create date given number of milliseconds since 1970-01-01T00:00:00Z (UTC)Date::set_time: Set the date fields from milliseconds since 1970-01-01T00:00:00ZDate::get_time: Returns the number of milliseconds since 1970-01-01T00:00:00Z (UTC)Date::to_iso_string: Returns a string representing the Date in ISO 8601 extended format.
use gistools::util::Date;
let date = Date::new(2022, 1, 1);
assert_eq!(date.to_iso_string(), "2022-01-01T00:00:00.000Z");Fields§
§year: u16Year
month: u8Month
day: u8Day
hour: u8Hour
minute: u8Minute
second: u8Second
Implementations§
Source§impl Date
impl Date
Sourcepub fn new_full(
year: u16,
month: u8,
day: u8,
hour: u8,
minute: u8,
second: u8,
) -> Date
pub fn new_full( year: u16, month: u8, day: u8, hour: u8, minute: u8, second: u8, ) -> Date
Creates a full Date
Sourcepub fn from_time(time: i64) -> Date
pub fn from_time(time: i64) -> Date
Create date given number of milliseconds since 1970-01-01T00:00:00Z (UTC)
Sourcepub fn set_time(&mut self, time: i64)
pub fn set_time(&mut self, time: i64)
Set the date fields from milliseconds since 1970-01-01T00:00:00Z
Sourcepub fn get_time(&self) -> i64
pub fn get_time(&self) -> i64
Returns the number of milliseconds since 1970-01-01T00:00:00Z (UTC)
Sourcepub fn to_iso_string(&self) -> String
pub fn to_iso_string(&self) -> String
Returns a string representing the Date in ISO 8601 extended format.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Date
impl<'de> Deserialize<'de> for Date
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for Date
impl Ord for Date
Source§impl PartialOrd for Date
impl PartialOrd for Date
impl Copy for Date
impl Eq for Date
impl StructuralPartialEq for Date
Auto Trait Implementations§
impl Freeze for Date
impl RefUnwindSafe for Date
impl Send for Date
impl Sync for Date
impl Unpin for Date
impl UnwindSafe for Date
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().