Struct FixedOffset

struct FixedOffset { ... }

The time zone with fixed offset, from UTC-23:59:59 to UTC+23:59:59.

Using the TimeZone methods on a FixedOffset struct is the preferred way to construct DateTime<FixedOffset> instances. See the east_opt and west_opt methods for examples.

Implementations

impl FixedOffset

fn east(secs: i32) -> FixedOffset

Makes a new FixedOffset for the Eastern Hemisphere with given timezone difference. The negative secs means the Western Hemisphere.

Panics on the out-of-bound secs.

const fn east_opt(secs: i32) -> Option<FixedOffset>

Makes a new FixedOffset for the Eastern Hemisphere with given timezone difference. The negative secs means the Western Hemisphere.

Returns None on the out-of-bound secs.

Example

# #[cfg(feature = "alloc")] {
use chrono::{FixedOffset, TimeZone};
let hour = 3600;
let datetime =
    FixedOffset::east_opt(5 * hour).unwrap().with_ymd_and_hms(2016, 11, 08, 0, 0, 0).unwrap();
assert_eq!(&datetime.to_rfc3339(), "2016-11-08T00:00:00+05:00")
# }
fn west(secs: i32) -> FixedOffset

Makes a new FixedOffset for the Western Hemisphere with given timezone difference. The negative secs means the Eastern Hemisphere.

Panics on the out-of-bound secs.

const fn west_opt(secs: i32) -> Option<FixedOffset>

Makes a new FixedOffset for the Western Hemisphere with given timezone difference. The negative secs means the Eastern Hemisphere.

Returns None on the out-of-bound secs.

Example

# #[cfg(feature = "alloc")] {
use chrono::{FixedOffset, TimeZone};
let hour = 3600;
let datetime =
    FixedOffset::west_opt(5 * hour).unwrap().with_ymd_and_hms(2016, 11, 08, 0, 0, 0).unwrap();
assert_eq!(&datetime.to_rfc3339(), "2016-11-08T00:00:00-05:00")
# }
const fn local_minus_utc(self: &Self) -> i32

Returns the number of seconds to add to convert from UTC to the local time.

const fn utc_minus_local(self: &Self) -> i32

Returns the number of seconds to add to convert from the local time to UTC.

impl Clone for FixedOffset

fn clone(self: &Self) -> FixedOffset

impl Copy for FixedOffset

impl Debug for FixedOffset

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Display for FixedOffset

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Eq for FixedOffset

impl Freeze for FixedOffset

impl FromStr for FixedOffset

fn from_str(s: &str) -> Result<Self, <Self as >::Err>

impl Hash for FixedOffset

fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)

impl Offset for FixedOffset

fn fix(self: &Self) -> FixedOffset

impl PartialEq for FixedOffset

fn eq(self: &Self, other: &FixedOffset) -> bool

impl RefUnwindSafe for FixedOffset

impl Send for FixedOffset

impl StructuralPartialEq for FixedOffset

impl Sync for FixedOffset

impl TimeZone for FixedOffset

fn from_offset(offset: &FixedOffset) -> FixedOffset
fn offset_from_local_date(self: &Self, _local: &NaiveDate) -> MappedLocalTime<FixedOffset>
fn offset_from_local_datetime(self: &Self, _local: &NaiveDateTime) -> MappedLocalTime<FixedOffset>
fn offset_from_utc_date(self: &Self, _utc: &NaiveDate) -> FixedOffset
fn offset_from_utc_datetime(self: &Self, _utc: &NaiveDateTime) -> FixedOffset

impl Unpin for FixedOffset

impl UnsafeUnpin for FixedOffset

impl UnwindSafe for FixedOffset

impl<T> Any for FixedOffset

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for FixedOffset

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for FixedOffset

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for FixedOffset

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for FixedOffset

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for FixedOffset

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T> ToString for FixedOffset

fn to_string(self: &Self) -> String

impl<T, U> Into for FixedOffset

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for FixedOffset

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for FixedOffset

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>