pub struct DateTime { /* private fields */ }
Expand description
Struct to store date, time and timezone information altogether.
DateTime
is refcounted and immutable.
Date information is handled using the proleptic Gregorian calendar.
Provides basic creation functions and accessor functions to its fields.
GLib type: Shared boxed type with reference counted clone semantics.
Implementations§
source§impl DateTime
impl DateTime
sourcepub fn as_ptr(&self) -> *mut GstDateTime
pub fn as_ptr(&self) -> *mut GstDateTime
Return the inner pointer to the underlying C value.
sourcepub unsafe fn from_glib_ptr_borrow(ptr: &*mut GstDateTime) -> &Self
pub unsafe fn from_glib_ptr_borrow(ptr: &*mut GstDateTime) -> &Self
Borrows the underlying C value.
source§impl DateTime
impl DateTime
sourcepub fn from_g_date_time(dt: DateTime) -> DateTime
pub fn from_g_date_time(dt: DateTime) -> DateTime
sourcepub fn from_iso8601_string(string: &str) -> Result<DateTime, BoolError>
pub fn from_iso8601_string(string: &str) -> Result<DateTime, BoolError>
Tries to parse common variants of ISO-8601 datetime strings into a
DateTime
. Possible input formats are (for example):
2012-06-30T22:46:43Z
, 2012
, 2012-06
, 2012-06-30
, 2012-06-30T22:46:43-0430
,
2012-06-30T22:46Z
, 2012-06-30T22:46-0430
, 2012-06-30 22:46
,
2012-06-30 22:46:43
, 2012-06-00
, 2012-00-00
, 2012-00-30
, 22:46:43Z
, 22:46Z
,
22:46:43-0430
, 22:46-0430
, 22:46:30
, 22:46
If no date is provided, it is assumed to be “today” in the timezone
provided (if any), otherwise UTC.
§string
ISO 8601-formatted datetime string.
§Returns
sourcepub fn new_now_local_time() -> Option<DateTime>
pub fn new_now_local_time() -> Option<DateTime>
sourcepub fn new_now_utc() -> Option<DateTime>
pub fn new_now_utc() -> Option<DateTime>
sourcepub fn year(&self) -> i32
pub fn year(&self) -> i32
Returns the year of this DateTime
.
Call has_year()
before, to avoid warnings.
§Returns
The year of this DateTime
sourcepub fn to_g_date_time(&self) -> Result<DateTime, BoolError>
pub fn to_g_date_time(&self) -> Result<DateTime, BoolError>
Creates a new glib::DateTime
from a fully defined DateTime
object.
§Returns
a newly created glib::DateTime
, or
None
on error or if self
does not have a year, month, day, hour,
minute and second.
sourcepub fn to_iso8601_string(&self) -> Result<GString, BoolError>
pub fn to_iso8601_string(&self) -> Result<GString, BoolError>
Create a minimal string compatible with ISO-8601. Possible output formats
are (for example): 2012
, 2012-06
, 2012-06-23
, 2012-06-23T23:30Z
,
2012-06-23T23:30+0100
, 2012-06-23T23:30:59Z
, 2012-06-23T23:30:59+0100
§Returns
a newly allocated string formatted according
to ISO 8601 and only including the datetime fields that are
valid, or None
in case there was an error.
source§impl DateTime
impl DateTime
sourcepub fn new(
tzoffset: impl Into<Option<f32>>,
year: impl Into<i32>,
month: impl Into<Option<i32>>,
day: impl Into<Option<i32>>,
hour: impl Into<Option<i32>>,
minute: impl Into<Option<i32>>,
seconds: impl Into<Option<f64>>,
) -> Result<DateTime, BoolError>
pub fn new( tzoffset: impl Into<Option<f32>>, year: impl Into<i32>, month: impl Into<Option<i32>>, day: impl Into<Option<i32>>, hour: impl Into<Option<i32>>, minute: impl Into<Option<i32>>, seconds: impl Into<Option<f64>>, ) -> Result<DateTime, BoolError>
Creates a new DateTime
using the date and times in the gregorian calendar
in the supplied timezone.
year
should be from 1 to 9999, month
should be from 1 to 12, day
from
1 to 31, hour
from 0 to 23, minutes
and seconds
from 0 to 59.
Note that tzoffset
is a float and was chosen so for being able to handle
some fractional timezones, while it still keeps the readability of
representing it in hours for most timezones.
If value is -1 then all over value will be ignored. For example
if month
== -1, then DateTime
will be created only for year
. If
day
== -1, then DateTime
will be created for year
and month
and
so on.
§tzoffset
Offset from UTC in hours.
§year
the gregorian year
§month
the gregorian month
§day
the day of the gregorian month
§hour
the hour of the day
§minute
the minute of the hour
§seconds
the second of the minute
§Returns
pub fn from_local_time( year: impl Into<i32>, month: impl Into<Option<i32>>, day: impl Into<Option<i32>>, hour: impl Into<Option<i32>>, minute: impl Into<Option<i32>>, seconds: impl Into<Option<f64>>, ) -> Result<DateTime, BoolError>
pub fn from_y(year: i32) -> Result<DateTime, BoolError>
pub fn from_ym(year: i32, month: i32) -> Result<DateTime, BoolError>
pub fn from_ymd(year: i32, month: i32, day: i32) -> Result<DateTime, BoolError>
sourcepub fn hour(&self) -> Option<i32>
pub fn hour(&self) -> Option<i32>
Retrieves the hour of the day represented by self
in the gregorian
calendar. The return is in the range of 0 to 23.
§Returns
the hour of the day, or -1 if none is set.
sourcepub fn microsecond(&self) -> Option<i32>
pub fn microsecond(&self) -> Option<i32>
Retrieves the fractional part of the seconds in microseconds represented by
self
in the gregorian calendar.
§Returns
the microsecond of the second, or -1 if none is set.
sourcepub fn minute(&self) -> Option<i32>
pub fn minute(&self) -> Option<i32>
Retrieves the minute of the hour represented by self
in the gregorian
calendar.
§Returns
the minute of the hour, or -1 if none is set.
sourcepub fn second(&self) -> Option<i32>
pub fn second(&self) -> Option<i32>
Retrieves the second of the minute represented by self
in the gregorian
calendar.
§Returns
the second represented by self
, or -1 if none is set.
sourcepub fn time_zone_offset(&self) -> Option<f32>
pub fn time_zone_offset(&self) -> Option<f32>
Retrieves the offset from UTC in hours that the timezone specified
by self
represents. Timezones ahead (to the east) of UTC have positive
values, timezones before (to the west) of UTC have negative values.
If self
represents UTC time, then the offset is zero.
§Returns
the offset from UTC in hours, or G_MAXFLOAT
if none is set.
pub fn to_utc(&self) -> Result<DateTime, BoolError>
Trait Implementations§
source§impl<'de> Deserialize<'de> for DateTime
impl<'de> Deserialize<'de> for DateTime
source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
source§impl HasParamSpec for DateTime
impl HasParamSpec for DateTime
source§impl PartialEq for DateTime
impl PartialEq for DateTime
source§impl PartialOrd for DateTime
impl PartialOrd for DateTime
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 DateTime
impl StaticType for DateTime
source§fn static_type() -> Type
fn static_type() -> Type
Self
.impl Send for DateTime
impl Sync for DateTime
Auto Trait Implementations§
impl Freeze for DateTime
impl RefUnwindSafe for DateTime
impl Unpin for DateTime
impl UnwindSafe for DateTime
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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>,
unsafe fn from_glib_none_as_vec(ptr: *const GList) -> Vec<T>
unsafe fn from_glib_container_as_vec(_: *const GList) -> Vec<T>
unsafe fn from_glib_full_as_vec(_: *const GList) -> Vec<T>
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>,
unsafe fn from_glib_none_as_vec(ptr: *const GPtrArray) -> Vec<T>
unsafe fn from_glib_container_as_vec(_: *const GPtrArray) -> Vec<T>
unsafe fn from_glib_full_as_vec(_: *const GPtrArray) -> Vec<T>
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>,
unsafe fn from_glib_none_as_vec(ptr: *const GSList) -> Vec<T>
unsafe fn from_glib_container_as_vec(_: *const GSList) -> Vec<T>
unsafe fn from_glib_full_as_vec(_: *const GSList) -> Vec<T>
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>,
unsafe fn from_glib_none_as_vec(ptr: *mut GList) -> Vec<T>
unsafe fn from_glib_container_as_vec(ptr: *mut GList) -> Vec<T>
unsafe fn from_glib_full_as_vec(ptr: *mut GList) -> Vec<T>
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>,
unsafe fn from_glib_none_as_vec(ptr: *mut GPtrArray) -> Vec<T>
unsafe fn from_glib_container_as_vec(ptr: *mut GPtrArray) -> Vec<T>
unsafe fn from_glib_full_as_vec(ptr: *mut GPtrArray) -> Vec<T>
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>,
unsafe fn from_glib_none_as_vec(ptr: *mut GSList) -> Vec<T>
unsafe fn from_glib_container_as_vec(ptr: *mut GSList) -> Vec<T>
unsafe fn from_glib_full_as_vec(ptr: *mut GSList) -> Vec<T>
source§impl<T> IntoClosureReturnValue for T
impl<T> IntoClosureReturnValue for T
fn into_closure_return_value(self) -> Option<Value>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> PropertyGet for Twhere
T: HasParamSpec,
impl<T> PropertyGet for Twhere
T: HasParamSpec,
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> ToSendValue for T
impl<T> ToSendValue for T
source§fn to_send_value(&self) -> SendValue
fn to_send_value(&self) -> SendValue
SendValue
clone of self
.