Struct utc_datetime::UtcDatetime [−][src]
pub struct UtcDatetime { /* fields omitted */ }
Implementations
Create a new UtcDateTime structure
Returns the number of seconds since January 1, 1970
Example
use utc_datetime::UtcDatetime;
let anew_date=UtcDatetime::new(2020,2,2,2,2,2).unwrap();
assert_eq!(anew_date.timestamp().unwrap(),1580608922)
Return today is the day of the week,Monday to Saturday Return 1 to 6,Sunday return 0
Example
use utc_datetime::UtcDatetime;
let a_date=UtcDatetime::new(2021,11,15,0,0,0).unwrap();
assert_eq!(a_date.weekday(),1);
Convert a string containing time to UtcDatetime.
Time strings must be sorted by year, month, day, hour, minute, and second, and Non-arabic numbers can be used as separators.
Parsable string example:“2020-12-31 23:59:59”,“2020z12z31z23z59z59”.
Example
use utc_datetime::UtcDatetime;
let datetime=UtcDatetime::from_string("时间:2020年12月31日23点59分59秒").unwrap();
assert_eq!(datetime,UtcDatetime::new(2020,12,31,23,59,59).unwrap());
Trait Implementations
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more