FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    DateTimeOffset

    struct · ferroui-base · v0.5.0

    struct DateTimeOffset
    

    A date and time of day relative to UTC.

    Equality, ordering and hashing consider the UTC instant only: two values with different offsets that name the same instant are equal, as in .NET (use equals_exact to compare the offsets too).

    View source

    Members

    MIN_VALUE

    const MIN_VALUE: DateTimeOffset
    

    The smallest value, 0001-01-01T00:00:00 +00:00.

    Source

    MAX_VALUE

    const MAX_VALUE: DateTimeOffset
    

    The largest value, 9999-12-31T23:59:59.9999999 +00:00.

    Source

    UNIX_EPOCH

    const UNIX_EPOCH: DateTimeOffset
    

    1970-01-01T00:00:00 +00:00.

    Source

    new

    fn new(year: i32, month: i32, day: i32, hour: i32, minute: i32, second: i32, offset: SignedDuration) -> DateTimeOffset
    

    The given clock date and time at offset from UTC. Panics when the date and time are invalid, the offset is not a whole number of minutes within 14 hours of UTC, or the UTC instant is out of range.

    Source

    try_new

    fn try_new(year: i32, month: i32, day: i32, hour: i32, minute: i32, second: i32, offset: SignedDuration) -> Option<DateTimeOffset>
    

    Like new; None instead of a panic.

    Source

    from_ticks

    fn from_ticks(ticks: i64, offset: SignedDuration) -> DateTimeOffset
    

    The clock time with ticks ticks at offset from UTC. Panics when the ticks, the offset or the UTC instant are out of range.

    Source

    from_date_time

    fn from_date_time(date_time: DateTime) -> DateTimeOffset
    

    The instant of a DateTime: a UTC value gets the offset zero, a local or unspecified value the local offset at that time (.NET new DateTimeOffset(DateTime)). Panics when the UTC instant is out of range.

    Source

    from_date_time_offset

    fn from_date_time_offset(date_time: DateTime, offset: SignedDuration) -> DateTimeOffset
    

    The clock time date_time at offset from UTC (.NET new DateTimeOffset(DateTime, TimeSpan)). Panics when the offset is invalid, when a UTC value is given a non-zero offset, when a local value is given an offset other than the local one, or when the UTC instant is out of range.

    Source

    now

    fn now() -> DateTimeOffset
    

    The current date and time with the local offset.

    Source

    utc_now

    fn utc_now() -> DateTimeOffset
    

    The current date and time with the offset zero.

    Source

    offset

    const fn offset(self: Self) -> SignedDuration
    

    The offset from UTC.

    Source

    date_time

    const fn date_time(self: Self) -> DateTime
    

    The clock date and time, of unspecified kind (.NET DateTime).

    Source

    utc_date_time

    const fn utc_date_time(self: Self) -> DateTime
    

    The UTC date and time, of kind UTC (.NET UtcDateTime).

    Source

    local_date_time

    fn local_date_time(self: Self) -> DateTime
    

    The date and time in local time, of kind local (.NET LocalDateTime).

    Source

    date

    const fn date(self: Self) -> DateTime
    

    The clock date at midnight, of unspecified kind.

    Source

    time_of_day

    const fn time_of_day(self: Self) -> SignedDuration
    

    The clock time elapsed since midnight.

    Source

    ticks

    const fn ticks(self: Self) -> i64
    

    The ticks of the clock date and time.

    Source

    utc_ticks

    const fn utc_ticks(self: Self) -> i64
    

    The ticks of the UTC date and time.

    Source

    year

    fn year(self: Self) -> i32
    

    The year of the clock date.

    Source

    month

    fn month(self: Self) -> i32
    

    The month of the clock date, 1..=12.

    Source

    day

    fn day(self: Self) -> i32
    

    The day of the month of the clock date, 1..=31.

    Source

    day_of_year

    fn day_of_year(self: Self) -> i32
    

    The day of the year of the clock date, 1..=366.

    Source

    day_of_week

    fn day_of_week(self: Self) -> DayOfWeek
    

    The day of the week of the clock date.

    Source

    hour

    const fn hour(self: Self) -> i32
    

    The hour of the clock time, 0..=23.

    Source

    minute

    const fn minute(self: Self) -> i32
    

    The minute of the clock time, 0..=59.

    Source

    second

    const fn second(self: Self) -> i32
    

    The second of the clock time, 0..=59.

    Source

    millisecond

    const fn millisecond(self: Self) -> i32
    

    The millisecond of the clock time, 0..=999.

    Source

    add

    fn add(self: Self, value: SignedDuration) -> DateTimeOffset
    

    The value value later, with the same offset. Panics when out of range.

    Source

    subtract

    fn subtract(self: Self, value: SignedDuration) -> DateTimeOffset
    

    The value value earlier, with the same offset. Panics when out of range.

    Source

    subtract_date_time_offset

    fn subtract_date_time_offset(self: Self, other: DateTimeOffset) -> SignedDuration
    

    The interval from other to this value (by UTC instants).

    Source

    add_days

    fn add_days(self: Self, value: f64) -> DateTimeOffset
    

    The value value days later. Panics when out of range.

    Source

    add_months

    fn add_months(self: Self, months: i32) -> DateTimeOffset
    

    The value months months later (see DateTime::add_months).

    Source

    add_years

    fn add_years(self: Self, years: i32) -> DateTimeOffset
    

    The value years years later (see DateTime::add_years).

    Source

    to_offset

    fn to_offset(self: Self, offset: SignedDuration) -> DateTimeOffset
    

    The same instant at another offset. Panics when the offset is invalid or the clock time at that offset is out of range.

    Source

    to_local_time

    fn to_local_time(self: Self) -> DateTimeOffset
    

    The same instant at the local offset. A clock time that would leave the range keeps the instant and gets the offset zero.

    Source

    to_universal_time

    const fn to_universal_time(self: Self) -> DateTimeOffset
    

    The same instant at the offset zero.

    Source

    compare

    fn compare(first: DateTimeOffset, second: DateTimeOffset) -> i32
    

    Compares two values by their UTC instants: -1, 0 or 1.

    Source

    compare_to

    fn compare_to(self: Self, other: DateTimeOffset) -> i32
    

    Compares this value with other by their UTC instants: -1, 0 or 1.

    Source

    equals_exact

    fn equals_exact(self: Self, other: DateTimeOffset) -> bool
    

    Whether both the UTC instant and the offset are the same.

    Source

    to_string_format

    fn to_string_format(self: Self, format: &str, provider: &impl DateTimeFormatProvider + ?Sized) -> String
    

    Formats with a standard or custom .NET date and time format string and the conventions of provider. An empty format gives the short date, the long time and the offset ("G" followed by zzz). Panics when the format string is invalid (.NET throws FormatException).

    Source

    try_to_string_format

    fn try_to_string_format(self: Self, format: &str, provider: &impl DateTimeFormatProvider + ?Sized) -> Result<String, FormatError>
    

    Like to_string_format, but gives the error of an invalid format string.

    Source

    to_string_with

    fn to_string_with(self: Self, format: &str) -> String
    

    Formats with a format string and the conventions of the current culture (.NET ToString(string)). Panics when the format is invalid.

    Source

    to_string_provider

    fn to_string_provider(self: Self, provider: &impl DateTimeFormatProvider + ?Sized) -> String
    

    Formats with the default format and the conventions of provider (.NET ToString(IFormatProvider)).

    Source

    parse

    fn parse(text: &str, provider: &impl DateTimeFormatProvider + ?Sized) -> Result<DateTimeOffset, FormatError>
    

    Parses a date and time with an optional offset written in the conventions of provider (.NET DateTimeOffset.Parse(string, IFormatProvider)): the forms DateTime::parse accepts. The value has the offset the text states; a text without an offset is a local time and gets the local offset at that time, and a text without a date the current local date, as in .NET. The offset is Z, GMT, or a signed hh:mm, hhmm or h[h] after the time or the date. An offset of more than 14 hours and an instant outside of the years 1 to 9999 are errors.

    Checked against results recorded from .NET for the invariant culture (date_time_tests.rs, date_time_offset_parse_matches_net). Not supported, as for DateTime::parse: what the heuristic parser of .NET accepts beyond those forms (other time zone names, era names), the DateTimeStyles overloads and ParseExact.

    Source

    try_parse

    fn try_parse(text: &str, provider: &impl DateTimeFormatProvider + ?Sized) -> Option<DateTimeOffset>
    

    Parses like parse; None on failure (.NET DateTimeOffset.TryParse).

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • ResourceKeyObject
    • PropertyValue
    • AnyValue
    • ClassDefaults
    • Borrow<T>
    • BorrowMut<T>
    • CloneToUninit
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ToOwned
    • ToString
    • ErasedDestructor
    • IntoEither
    • Clone
    • Copy
    • FromStr
    • Default
    • From<DateTime>
    • TryFrom<SystemTime>
    • TryFrom<DateTimeOffset>
    • PartialEq
    • Eq
    • PartialOrd
    • Ord
    • Hash
    • Add<SignedDuration>
    • Sub<SignedDuration>
    • Sub
    • AddAssign<SignedDuration>
    • SubAssign<SignedDuration>
    • Display
    • Debug
    • MarkupTyped
    • ValueTypeRegistration

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.