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
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.
chrono only.Convert to a chrono::NaiveDate
This is supported on crate feature chrono only.
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
Convenience chrono::Datelike implementation, which mostly relies on internal conversion to chrono::NaiveDate.
Returns the year number in the calendar date.
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
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
impl RefUnwindSafe for DateTime
impl UnwindSafe for DateTime
Blanket Implementations
Mutably borrows from an owned value. Read more