Struct Utc
pub struct Utc;
The UTC time zone. This is the most efficient time zone when you don't need the local time. It is also used as an offset (which is also a dummy type).
Using the TimeZone methods
on the UTC struct is the preferred way to construct DateTime<Utc>
instances.
Example
use ;
let dt = from_timestamp.unwrap;
assert_eq!;
assert_eq!;
Implementations
impl Utc
fn today() -> Date<Utc>Returns a
Datewhich corresponds to the current date.fn now() -> DateTime<Utc>Returns a
DateTime<Utc>which corresponds to the current date and time in UTC.See also the similar
Local::now()which returnsDateTime<Local>, i.e. the local date and time including offset from UTC.Example
# # use ; // Current time in UTC let now_utc = now; // Current date in UTC let today_utc = now_utc.date_naive; // Current time in some timezone (let's use +05:00) let offset = east_opt.unwrap; let now_with_offset = now.with_timezone;
Trait Implementations
impl Clone for Utc
fn clone(&self) -> Self
impl Copy for Utc
impl Debug for Utc
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Display for Utc
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Eq for Utc
impl Hash for Utc
fn hash<__H: Hasher>(&self, state: &mut __H)
impl Offset for Utc
fn fix(&self) -> FixedOffset
impl PartialEq for Utc
fn eq(&self, other: &Self) -> bool
impl StructuralPartialEq for Utc
impl TimeZone for Utc
type Offset = Utc;fn from_offset(_state: &Utc) -> Utcfn offset_from_local_date(&self, _local: &NaiveDate) -> MappedLocalTime<Utc>fn offset_from_local_datetime(&self, _local: &NaiveDateTime) -> MappedLocalTime<Utc>fn offset_from_utc_date(&self, _utc: &NaiveDate) -> Utcfn offset_from_utc_datetime(&self, _utc: &NaiveDateTime) -> Utc
Auto Trait Implementations
impl Freeze for Utc
impl RefUnwindSafe for Utc
impl Send for Utc
impl Sync for Utc
impl Unpin for Utc
impl UnsafeUnpin for Utc
impl UnwindSafe for Utc
Blanket Implementations
impl<T> Any for Utc
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Utc
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Utc
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Utc
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Utc
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Utc
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T> ToString for Utc
where
T: Display + ?Sized,
fn to_string(&self) -> String
impl<T, U> Into<U> for Utc
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Utc
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Utc
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>