Struct tzdata::Datetime [] [src]

pub struct Datetime<'a> { /* fields omitted */ }

A precise point in time along associated to a Timezone.

The Datetime cannot be created on its own as it depends on a Timezone. tzdata does not expose a naive flavor of Datetime. To build a Datetime, instanciate a Timezone first and call the desired method.

let paris = tzdata::Timezone::new("Europe/Paris").unwrap();
let midnight_in_paris = paris.datetime(2015, 12, 25, 0, 0, 0, 0);

let utc = tzdata::Timezone::utc();
let t = midnight_in_paris.project(&utc);

assert_eq!(t.date(), (2015, 12, 24));
assert_eq!(t.time(), (23, 0, 0, 0));

Methods

impl<'a> Datetime<'a>
[src]

Project the current Datetime in another Timezone.

Return the date component of the Datetime expressed in the associated Timezone. The tuple holds the year, month and day in this order.

Return the time component of the Datetime expressed in the associated Timezone. The tuple holds the hour, minute, second and nanosecond in this order.

Return the unix timestamp. This is the number of unix seconds since 1970-01-01T00:00:00Z.

Format the Datetime according to the provided format. The following control characters are implemented:

  • %%: the '%' character
  • %Y: year (2006)
  • %m: month (01)
  • %d: day of the month (02)
  • %e: day of the month (2)
  • %H: hour (15)
  • %M: minute (04)
  • %S: second (05)
  • %3: millisecond (123)
  • %6: microsecond (123456)
  • %9: nanosecond (123456789)
  • %x: UTC offset (+02:00 or -05:00)
  • %z: UTC offset (+0200 or -0500)
  • %Z: timezone abbreviation (CET)
  • %w: weekday (1)
  • %a: abbreviated weekday name (Mon)
  • %A: full weekday name (Monday)
  • %b: abbreviated month name (Jan)
  • %B: full month name (January)
  • %C: century (20)

Panics if the format is invalid.

Format Datetime according to RFC 3339 format.

Format Datetime according to RFC 2822 format.

Trait Implementations

impl<'a> PartialEq<Datetime<'a>> for Datetime<'a>
[src]

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

This method tests for !=.

impl<'a> Eq for Datetime<'a>
[src]

impl<'a> PartialOrd<Datetime<'a>> for Datetime<'a>
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<'a> Ord for Datetime<'a>
[src]

This method returns an Ordering between self and other. Read more

impl<'a> Add<Deltatime> for Datetime<'a>
[src]

The resulting type after applying the + operator

The method for the + operator

impl<'a> Sub<Deltatime> for Datetime<'a>
[src]

The resulting type after applying the - operator

The method for the - operator

impl<'a> Debug for Datetime<'a>
[src]

Formats the value using the given formatter.