#[repr(transparent)]pub struct TimeZone { /* private fields */ }
Expand description
TimeZone
is an opaque structure whose members cannot be accessed
directly.
Implementations§
source§impl TimeZone
impl TimeZone
sourcepub fn new(identifier: Option<&str>) -> TimeZone
pub fn new(identifier: Option<&str>) -> TimeZone
A version of from_identifier()
which returns the UTC time zone
if identifier
could not be parsed or loaded.
If you need to check whether identifier
was loaded successfully, use
from_identifier()
.
Deprecated since 2.68
Use from_identifier()
instead, as it provides
error reporting. Change your code to handle a potentially None
return
value.
identifier
a timezone identifier
Returns
the requested timezone
sourcepub fn from_identifier(identifier: Option<&str>) -> Option<TimeZone>
Available on crate feature v2_68
only.
pub fn from_identifier(identifier: Option<&str>) -> Option<TimeZone>
v2_68
only.Creates a TimeZone
corresponding to identifier
. If identifier
cannot be
parsed or loaded, None
is returned.
identifier
can either be an RFC3339/ISO 8601 time offset or
something that would pass as a valid value for the TZ
environment
variable (including None
).
In Windows, identifier
can also be the unlocalized name of a time
zone for standard time, for example “Pacific Standard Time”.
Valid RFC3339 time offsets are "Z"
(for UTC) or
"±hh:mm"
. ISO 8601 additionally specifies
"±hhmm"
and "±hh"
. Offsets are
time values to be added to Coordinated Universal Time (UTC) to get
the local time.
In UNIX, the TZ
environment variable typically corresponds
to the name of a file in the zoneinfo database, an absolute path to a file
somewhere else, or a string in
“std offset [dst [offset],start[/time],end[/time]]” (POSIX) format.
There are no spaces in the specification. The name of standard
and daylight savings time zone must be three or more alphabetic
characters. Offsets are time values to be added to local time to
get Coordinated Universal Time (UTC) and should be
"[±]hh[[:]mm[:ss]]"
. Dates are either
"Jn"
(Julian day with n between 1 and 365, leap
years not counted), "n"
(zero-based Julian day
with n between 0 and 365) or "Mm.w.d"
(day d
(0 <= d <= 6) of week w (1 <= w <= 5) of month m (1 <= m <= 12), day
0 is a Sunday). Times are in local wall clock time, the default is
02:00:00.
In Windows, the “tzn[+|–]hh[:mm[:ss]][dzn]” format is used, but also accepts POSIX format. The Windows format uses US rules for all time zones; daylight savings time is 60 minutes behind the standard time with date and time of change taken from Pacific Standard Time. Offsets are time values to be added to the local time to get Coordinated Universal Time (UTC).
local()
calls this function with the value of the
TZ
environment variable. This function itself is independent of
the value of TZ
, but if identifier
is None
then /etc/localtime
will be consulted to discover the correct time zone on UNIX and the
registry will be consulted or GetTimeZoneInformation() will be used
to get the local time zone on Windows.
If intervals are not available, only time zone rules from TZ
environment variable or other means, then they will be computed
from year 1900 to 2037. If the maximum year for the rules is
available and it is greater than 2037, then it will followed
instead.
See
RFC3339 §5.6
for a precise definition of valid RFC3339 time offsets
(the time-offset
expansion) and ISO 8601 for the
full list of valid time offsets. See
The GNU C Library manual
for an explanation of the possible
values of the TZ
environment variable. See
Microsoft Time Zone Index Values
for the list of time zones on Windows.
You should release the return value by calling g_time_zone_unref()
when you are done with it.
identifier
a timezone identifier
Returns
the requested timezone, or None
on
failure
sourcepub fn local() -> TimeZone
pub fn local() -> TimeZone
Creates a TimeZone
corresponding to local time. The local time
zone may change between invocations to this function; for example,
if the system administrator changes it.
This is equivalent to calling new()
with the value of
the TZ
environment variable (including the possibility of None
).
You should release the return value by calling g_time_zone_unref()
when you are done with it.
Returns
the local timezone
sourcepub fn from_offset(seconds: i32) -> TimeZone
Available on crate feature v2_58
only.
pub fn from_offset(seconds: i32) -> TimeZone
v2_58
only.sourcepub fn find_interval(&self, type_: TimeType, time_: i64) -> i32
pub fn find_interval(&self, type_: TimeType, time_: i64) -> i32
Finds an interval within self
that corresponds to the given time_
.
The meaning of time_
depends on type_
.
If type_
is TimeType::Universal
then this function will always
succeed (since universal time is monotonic and continuous).
Otherwise time_
is treated as local time. The distinction between
TimeType::Standard
and TimeType::Daylight
is ignored except in
the case that the given time_
is ambiguous. In Toronto, for example,
01:30 on November 7th 2010 occurred twice (once inside of daylight
savings time and the next, an hour later, outside of daylight savings
time). In this case, the different value of type_
would result in a
different interval being returned.
It is still possible for this function to fail. In Toronto, for example, 02:00 on March 14th 2010 does not exist (due to the leap forward to begin daylight savings time). -1 is returned in that case.
type_
the TimeType
of time_
time_
a number of seconds since January 1, 1970
Returns
the interval containing time_
, or -1 in case of failure
sourcepub fn abbreviation(&self, interval: i32) -> GString
pub fn abbreviation(&self, interval: i32) -> GString
Determines the time zone abbreviation to be used during a particular
interval
of time in the time zone self
.
For example, in Toronto this is currently “EST” during the winter months and “EDT” during the summer months when daylight savings time is in effect.
interval
an interval within the timezone
Returns
the time zone abbreviation, which belongs to self
sourcepub fn identifier(&self) -> GString
Available on crate feature v2_58
only.
pub fn identifier(&self) -> GString
v2_58
only.Get the identifier of this TimeZone
, as passed to new()
.
If the identifier passed at construction time was not recognised, UTC
will
be returned. If it was None
, the identifier of the local timezone at
construction time will be returned.
The identifier will be returned in the same format as provided at construction time: if provided as a time offset, that will be returned by this function.
Returns
identifier for this timezone
sourcepub fn offset(&self, interval: i32) -> i32
pub fn offset(&self, interval: i32) -> i32
Determines the offset to UTC in effect during a particular interval
of time in the time zone self
.
The offset is the number of seconds that you add to UTC time to
arrive at local time for self
(ie: negative numbers for time zones
west of GMT, positive numbers for east).
interval
an interval within the timezone
Returns
the number of seconds that should be added to UTC to get the
local time in self
Trait Implementations§
source§impl Ord for TimeZone
impl Ord for TimeZone
source§impl PartialEq<TimeZone> for TimeZone
impl PartialEq<TimeZone> for TimeZone
source§impl PartialOrd<TimeZone> for TimeZone
impl PartialOrd<TimeZone> for TimeZone
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl StaticType for TimeZone
impl StaticType for TimeZone
source§fn static_type() -> Type
fn static_type() -> Type
Self
.impl Eq for TimeZone
impl Send for TimeZone
impl StructuralEq for TimeZone
impl StructuralPartialEq for TimeZone
impl Sync for TimeZone
Auto Trait Implementations§
Blanket Implementations§
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
source§impl<T> StaticTypeExt for Twhere
T: StaticType,
impl<T> StaticTypeExt for Twhere T: StaticType,
source§fn ensure_type()
fn ensure_type()
source§impl<T> ToClosureReturnValue for Twhere
T: ToValue,
impl<T> ToClosureReturnValue for Twhere T: ToValue,
fn to_closure_return_value(&self) -> Option<Value>
source§impl<T> ToSendValue for Twhere
T: Send + ToValue + ?Sized,
impl<T> ToSendValue for Twhere T: Send + ToValue + ?Sized,
source§fn to_send_value(&self) -> SendValue
fn to_send_value(&self) -> SendValue
SendValue
clone of self
.