Struct chrono::datetime::DateTime [] [src]

pub struct DateTime<Tz: TimeZone> {
    // some fields omitted
}

ISO 8601 combined date and time with time zone.

Methods

impl<Tz: TimeZone> DateTime<Tz>

fn from_utc(datetime: NaiveDateTime, offset: Tz::Offset) -> DateTime<Tz>

Makes a new DateTime with given UTC datetime and offset. The local datetime should be constructed via the TimeZone trait.

fn date(&self) -> Date<Tz>

Retrieves a date component.

fn time(&self) -> NaiveTime

Retrieves a time component. Unlike date, this is not associated to the time zone.

fn timestamp(&self) -> i64

Returns the number of non-leap seconds since January 1, 1970 0:00:00 UTC (aka "UNIX timestamp").

fn num_seconds_from_unix_epoch(&self) -> i64

Deprecated: Same to DateTime::timestamp.

fn offset<'a>(&'a self) -> &'a Tz::Offset

Retrieves an associated offset from UTC.

fn timezone(&self) -> Tz

Retrieves an associated time zone.

fn with_timezone<Tz2: TimeZone>(&self, tz: &Tz2) -> DateTime<Tz2>

Changes the associated time zone. This does not change the actual DateTime (but will change the string representation).

fn checked_add(self, rhs: Duration) -> Option<DateTime<Tz>>

Adds given Duration to the current date and time.

Returns None when it will result in overflow.

fn checked_sub(self, rhs: Duration) -> Option<DateTime<Tz>>

Subtracts given Duration from the current date and time.

Returns None when it will result in overflow.

fn naive_utc(&self) -> NaiveDateTime

Returns a view to the naive UTC datetime.

fn naive_local(&self) -> NaiveDateTime

Returns a view to the naive local datetime.

impl DateTime<FixedOffset>

fn parse_from_rfc2822(s: &str) -> ParseResult<DateTime<FixedOffset>>

Parses an RFC 2822 date and time string such as Tue, 1 Jul 2003 10:52:37 +0200, then returns a new DateTime with a parsed FixedOffset.

fn parse_from_rfc3339(s: &str) -> ParseResult<DateTime<FixedOffset>>

Parses an RFC 3339 and ISO 8601 date and time string such as 1996-12-19T16:39:57-08:00, then returns a new DateTime with a parsed FixedOffset.

Why isn't this named parse_from_iso8601? That's because ISO 8601 allows some freedom over the syntax and RFC 3339 exercises that freedom to rigidly define a fixed format.

fn parse_from_str(s: &str, fmt: &str) -> ParseResult<DateTime<FixedOffset>>

Parses a string with the specified format string and returns a new DateTime with a parsed FixedOffset. See the format::strftime module on the supported escape sequences.

See also Offset::datetime_from_str which gives a local DateTime on specific time zone.

impl<Tz: TimeZone> DateTime<Tz> where Tz::Offset: Display

fn to_rfc2822(&self) -> String

Returns an RFC 2822 date and time string such as Tue, 1 Jul 2003 10:52:37 +0200.

fn to_rfc3339(&self) -> String

Returns an RFC 3339 and ISO 8601 date and time string such as 1996-12-19T16:39:57-08:00.

fn format_with_items<'a, I>(&self, items: I) -> DelayedFormat<I> where I: Iterator<Item=Item<'a>> + Clone

Formats the combined date and time with the specified formatting items.

fn format<'a>(&self, fmt: &'a str) -> DelayedFormat<StrftimeItems<'a>>

Formats the combined date and time with the specified format string. See the format::strftime module on the supported escape sequences.

Trait Implementations

impl<Tz: TimeZone> Datelike for DateTime<Tz>

fn year(&self) -> i32

fn month(&self) -> u32

fn month0(&self) -> u32

fn day(&self) -> u32

fn day0(&self) -> u32

fn ordinal(&self) -> u32

fn ordinal0(&self) -> u32

fn weekday(&self) -> Weekday

fn isoweekdate(&self) -> (i32, u32, Weekday)

fn with_year(&self, year: i32) -> Option<DateTime<Tz>>

fn with_month(&self, month: u32) -> Option<DateTime<Tz>>

fn with_month0(&self, month0: u32) -> Option<DateTime<Tz>>

fn with_day(&self, day: u32) -> Option<DateTime<Tz>>

fn with_day0(&self, day0: u32) -> Option<DateTime<Tz>>

fn with_ordinal(&self, ordinal: u32) -> Option<DateTime<Tz>>

fn with_ordinal0(&self, ordinal0: u32) -> Option<DateTime<Tz>>

fn year_ce(&self) -> (bool, u32)

fn num_days_from_ce(&self) -> i32

impl<Tz: TimeZone> Timelike for DateTime<Tz>

fn hour(&self) -> u32

fn minute(&self) -> u32

fn second(&self) -> u32

fn nanosecond(&self) -> u32

fn with_hour(&self, hour: u32) -> Option<DateTime<Tz>>

fn with_minute(&self, min: u32) -> Option<DateTime<Tz>>

fn with_second(&self, sec: u32) -> Option<DateTime<Tz>>

fn with_nanosecond(&self, nano: u32) -> Option<DateTime<Tz>>

fn hour12(&self) -> (bool, u32)

fn num_seconds_from_midnight(&self) -> u32

impl<Tz: TimeZone> Copy for DateTime<Tz> where Tz::Offset: Copy

impl<Tz: TimeZone> Send for DateTime<Tz> where Tz::Offset: Send

impl<Tz: TimeZone, Tz2: TimeZone> PartialEq<DateTime<Tz2>> for DateTime<Tz>

fn eq(&self, other: &DateTime<Tz2>) -> bool

1.0.0fn ne(&self, other: &Rhs) -> bool

impl<Tz: TimeZone> Eq for DateTime<Tz>

impl<Tz: TimeZone> PartialOrd for DateTime<Tz>

fn partial_cmp(&self, other: &DateTime<Tz>) -> Option<Ordering>

1.0.0fn lt(&self, other: &Rhs) -> bool

1.0.0fn le(&self, other: &Rhs) -> bool

1.0.0fn gt(&self, other: &Rhs) -> bool

1.0.0fn ge(&self, other: &Rhs) -> bool

impl<Tz: TimeZone> Ord for DateTime<Tz>

fn cmp(&self, other: &DateTime<Tz>) -> Ordering

impl<Tz: TimeZone> Hash for DateTime<Tz>

fn hash<H: Hasher>(&self, state: &mut H)

1.3.0fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher

impl<Tz: TimeZone> Add<Duration> for DateTime<Tz>

type Output = DateTime<Tz>

fn add(self, rhs: Duration) -> DateTime<Tz>

impl<Tz: TimeZone, Tz2: TimeZone> Sub<DateTime<Tz2>> for DateTime<Tz>

type Output = Duration

fn sub(self, rhs: DateTime<Tz2>) -> Duration

impl<Tz: TimeZone> Sub<Duration> for DateTime<Tz>

type Output = DateTime<Tz>

fn sub(self, rhs: Duration) -> DateTime<Tz>

impl<Tz: TimeZone> Debug for DateTime<Tz>

fn fmt(&self, f: &mut Formatter) -> Result

impl<Tz: TimeZone> Display for DateTime<Tz> where Tz::Offset: Display

fn fmt(&self, f: &mut Formatter) -> Result

impl FromStr for DateTime<FixedOffset>

type Err = ParseError

fn from_str(s: &str) -> ParseResult<DateTime<FixedOffset>>

impl FromStr for DateTime<UTC>

type Err = ParseError

fn from_str(s: &str) -> ParseResult<DateTime<UTC>>

impl FromStr for DateTime<Local>

type Err = ParseError

fn from_str(s: &str) -> ParseResult<DateTime<Local>>

Derived Implementations

impl<Tz: Clone + TimeZone> Clone for DateTime<Tz> where Tz::Offset: Clone

fn clone(&self) -> DateTime<Tz>

1.0.0fn clone_from(&mut self, source: &Self)