Struct Utc
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;
impl Clone for Utc
fn clone(self: &Self) -> Utc
impl Copy for Utc
impl Debug for Utc
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Display for Utc
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Eq for Utc
impl Freeze for Utc
impl Hash for Utc
fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)
impl Offset for Utc
fn fix(self: &Self) -> FixedOffset
impl PartialEq for Utc
fn eq(self: &Self, other: &Utc) -> bool
impl RefUnwindSafe for Utc
impl Send for Utc
impl StructuralPartialEq for Utc
impl Sync for Utc
impl TimeZone for Utc
fn from_offset(_state: &Utc) -> Utcfn offset_from_local_date(self: &Self, _local: &NaiveDate) -> MappedLocalTime<Utc>fn offset_from_local_datetime(self: &Self, _local: &NaiveDateTime) -> MappedLocalTime<Utc>fn offset_from_utc_date(self: &Self, _utc: &NaiveDate) -> Utcfn offset_from_utc_datetime(self: &Self, _utc: &NaiveDateTime) -> Utc
impl Unpin for Utc
impl UnsafeUnpin for Utc
impl UnwindSafe for Utc
impl<T> Any for Utc
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Utc
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Utc
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for Utc
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for Utc
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Utc
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T> ToString for Utc
fn to_string(self: &Self) -> String
impl<T, U> Into for Utc
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Utc
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Utc
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>