Struct edtf::DateTime[][src]

pub struct DateTime { /* fields omitted */ }
Expand description

A DateTime object.

This has minimal introspection methods. It is not an attempt to build a complete DateTime API. Prefer to use its implementation of chrono::Datelike and chrono::Timelike or simply the DateTime::to_chrono method to use a specific chrono::TimeZone, all available with features = ["chrono"].

Also, its Display implementation is geared towards lossless EDTF parse-format roundtrips. It does not always produce valid RFC3339 timestamps, in particular TzOffset::Hours is rendered as +04 instead of +04:00. This is best considered a problem with the EDTF specification for allowing a useless extra timestamp format.

Implementations

Gets the date portion

Gets the time portion

Get the TzOffset. If None is returned, this represents a timestamp which did not specify a timezone.

If using the chrono interop, None means you should attempt to convert to a chrono::NaiveDate

This is supported on crate feature chrono only.

Convert to a chrono::NaiveDate

This is supported on crate feature chrono only.
use edtf::level_1::Edtf;
use chrono::TimeZone;

let utc = chrono::Utc;
assert_eq!(
    Edtf::parse("2004-02-29T01:47:00+05:00")
        .unwrap()
        .as_datetime()
        .unwrap()
        .to_chrono(&utc),
    utc.ymd(2004, 02, 28).and_hms(20, 47, 00)
);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Convenience chrono::Datelike implementation, which mostly relies on internal conversion to chrono::NaiveDate.

Returns the year number in the calendar date.

Returns the month number starting from 1. Read more

Returns the month number starting from 0. Read more

Returns the day of month starting from 1. Read more

Returns the day of month starting from 0. Read more

Returns the day of year starting from 1. Read more

Returns the day of year starting from 0. Read more

Returns the day of week.

Returns the ISO week.

Makes a new value with the year number changed. Read more

Makes a new value with the month number (starting from 1) changed. Read more

Makes a new value with the month number (starting from 0) changed. Read more

Makes a new value with the day of month (starting from 1) changed. Read more

Makes a new value with the day of month (starting from 0) changed. Read more

Makes a new value with the day of year (starting from 1) changed. Read more

Makes a new value with the day of year (starting from 0) changed. Read more

Returns the absolute year number starting from 1 with a boolean flag, which is false when the year predates the epoch (BCE/BC) and true otherwise (CE/AD). Read more

Counts the days in the proleptic Gregorian calendar, with January 1, Year 1 (CE) as day 1. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Returns the hour number from 0 to 23.

Returns the minute number from 0 to 59.

Returns the second number from 0 to 59.

Returns the number of nanoseconds since the whole non-leap second. The range from 1,000,000,000 to 1,999,999,999 represents the leap second. Read more

Makes a new value with the hour number changed. Read more

Makes a new value with the minute number changed. Read more

Makes a new value with the second number changed. Read more

Makes a new value with nanoseconds since the whole non-leap second changed. Read more

Returns the hour number from 1 to 12 with a boolean flag, which is false for AM and true for PM. Read more

Returns the number of non-leap seconds past the last midnight.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.