Struct hourglass::Timezone [] [src]

pub struct Timezone { /* fields omitted */ }

A timezone.

There are several ways to create a new Timezone. It can be loaded from the IANA Time Zone Database, following the Area/Location pattern (e.g. Europe/Paris) with Timezone::new. A Timezone can be created as a fixed offset from UTC with Timezone::fixed or UTC itself with Timezone::utc. Finally, the Timezone can match the system local timezone with Timezone::local.

Example

let utc = hourglass::Timezone::utc();
let now = utc.now();

for tzname in &["Europe/Paris", "America/New_York", "Asia/Seoul"] {
    let tz = hourglass::Timezone::new(tzname).unwrap();
    let now = now.project(&tz);
    println!("it is now {:?} in {}", now, tzname);
}

Methods

impl Timezone
[src]

[src]

Try to load a new Timezone. It assumes that the zoneinfo data are located under /usr/share/zoneinfo.

[src]

Load the local Timezone set by the system, disregarding the TZ environment variable.

[src]

Returns the UTC timezone.

[src]

Returns a fixed offset to UTC timezone. The provided offset is in seconds.

[src]

Create a Timezone from a POSIX TZ definition. See man 3 tzset for a description of the format.

[src]

Return the Datetime representing now, relative to this Timezone.

[src]

Parse a Datetime relative to this Timezone according to the given format. Timezone-related field are ignored. An InputError is returned if the string does not match the format.

[src]

Create a new Datetime from a Unix timestamp. The provided timestamp represents Unix seconds from the Epoch, discarding any leap seconds that may have happened in between. A Unix timestamp is ambiguous on leap second insertion (e.g. 1435708800 is equal to both 2015-06-30T23:59:60Z and 2015-07-01T00:00:00Z) however, unix will always choose the non-leap second. Return an InputError if nano ∉ [0, 999999999].

[src]

Create a new Datetime relative to this Timezone. An InputError is returned if the following constraints do not hold:

  • month ∊ [1, 12]
  • day ∊ [1, 31] and is valid within the month
  • hour ∊ [0, 23]
  • minute ∊ [0, 59]
  • second ∊ [0, 60]
  • nano ∊ [0, 999999999]