Struct gstreamer::DateTime

source ·
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

source

pub fn as_ptr(&self) -> *mut GstDateTime

Return the inner pointer to the underlying C value.

source

pub unsafe fn from_glib_ptr_borrow(ptr: &*mut GstDateTime) -> &Self

Borrows the underlying C value.

source§

impl DateTime

source

pub fn from_g_date_time(dt: DateTime) -> DateTime

Creates a new DateTime from a glib::DateTime object.

§dt

the glib::DateTime.

§Returns

a newly created DateTime, or None if dt is None.

source

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

a newly created DateTime, or None on error

source

pub fn from_unix_epoch_local_time(secs: i64) -> Result<DateTime, BoolError>

Creates a new DateTime using the time since Jan 1, 1970 specified by secs. The DateTime is in the local timezone.

§secs

seconds from the Unix epoch

§Returns

the newly created DateTime, or None on error.

source

pub fn from_unix_epoch_local_time_usecs( usecs: i64, ) -> Result<DateTime, BoolError>

Creates a new DateTime using the time since Jan 1, 1970 specified by usecs. The DateTime is in the local timezone.

§usecs

microseconds from the Unix epoch

§Returns

a newly created DateTime, or None on error.

source

pub fn from_unix_epoch_utc(secs: i64) -> Result<DateTime, BoolError>

Creates a new DateTime using the time since Jan 1, 1970 specified by secs. The DateTime is in the UTC timezone.

§secs

seconds from the Unix epoch

§Returns

the newly created DateTime, or None on error.

source

pub fn from_unix_epoch_utc_usecs(usecs: i64) -> Result<DateTime, BoolError>

Creates a new DateTime using the time since Jan 1, 1970 specified by usecs. The DateTime is in UTC.

§usecs

microseconds from the Unix epoch

§Returns

a newly created DateTime, or None on error.

source

pub fn new_now_local_time() -> Option<DateTime>

Creates a new DateTime representing the current date and time.

§Returns

the newly created DateTime which should be freed with gst_date_time_unref(), or None on error.

source

pub fn new_now_utc() -> Option<DateTime>

Creates a new DateTime that represents the current instant at Universal coordinated time.

§Returns

the newly created DateTime which should be freed with gst_date_time_unref(), or None on error.

source

pub fn year(&self) -> i32

Returns the year of this DateTime. Call has_year() before, to avoid warnings.

§Returns

The year of this DateTime

source

pub fn has_day(&self) -> bool

§Returns

true if self’s day field is set, otherwise false

source

pub fn has_month(&self) -> bool

§Returns

true if self’s month field is set, otherwise false

source

pub fn has_second(&self) -> bool

§Returns

true if self’s second field is set, otherwise false

source

pub fn has_time(&self) -> bool

§Returns

true if self’s hour and minute fields are set, otherwise false

source

pub fn has_year(&self) -> bool

§Returns

true if self’s year field is set (which should always be the case), otherwise false

source

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.

source

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

source

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

the newly created DateTime, or None on error.

source

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>

source

pub fn from_y(year: i32) -> Result<DateTime, BoolError>

source

pub fn from_ym(year: i32, month: i32) -> Result<DateTime, BoolError>

source

pub fn from_ymd(year: i32, month: i32, day: i32) -> Result<DateTime, BoolError>

source

pub fn day(&self) -> Option<i32>

Returns the day of the month of this DateTime.

§Returns

The day of this DateTime, or -1 if none is set.

source

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.

source

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.

source

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.

source

pub fn month(&self) -> Option<i32>

Returns the month of this DateTime. January is 1, February is 2, etc..

§Returns

The month of this DateTime, or -1 if none is set.

source

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.

source

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.

source

pub fn to_utc(&self) -> Result<DateTime, BoolError>

Trait Implementations§

source§

impl Clone for DateTime

source§

fn clone(&self) -> Self

Makes a clone of this shared reference.

This increments the strong reference count of the reference. Dropping the reference will decrement it again.

1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for DateTime

source§

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

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for DateTime

source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for DateTime

source§

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

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a DateTime> for DateTime

source§

fn from(v: &'a DateTime) -> DateTime

Converts to this type from the input type.
source§

impl From<DateTime> for DateTime

source§

fn from(v: DateTime) -> DateTime

Converts to this type from the input type.
source§

impl From<DateTime> for Value

source§

fn from(s: DateTime) -> Self

Converts to this type from the input type.
source§

impl HasParamSpec for DateTime

§

type ParamSpec = ParamSpecBoxed

§

type SetValue = DateTime

Preferred value to be used as setter for the associated ParamSpec.
§

type BuilderFn = fn(_: &str) -> ParamSpecBoxedBuilder<'_, DateTime>

source§

fn param_spec_builder() -> Self::BuilderFn

source§

impl PartialEq for DateTime

source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for DateTime

source§

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

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

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for DateTime

source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
source§

impl StaticType for DateTime

source§

fn static_type() -> Type

Returns the type identifier of Self.
source§

impl<'a> TryFrom<&'a DateTime> for DateTime

§

type Error = BoolError

The type returned in the event of a conversion error.
source§

fn try_from(v: &'a DateTime) -> Result<DateTime, BoolError>

Performs the conversion.
source§

impl TryFrom<DateTime> for DateTime

§

type Error = BoolError

The type returned in the event of a conversion error.
source§

fn try_from(v: DateTime) -> Result<DateTime, BoolError>

Performs the conversion.
source§

impl Send for DateTime

source§

impl Sync for DateTime

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

source§

unsafe fn from_glib_none_num_as_vec(ptr: *const GList, num: usize) -> Vec<T>

source§

unsafe fn from_glib_container_num_as_vec(_: *const GList, _: usize) -> Vec<T>

source§

unsafe fn from_glib_full_num_as_vec(_: *const GList, _: usize) -> Vec<T>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

source§

unsafe fn from_glib_none_num_as_vec(ptr: *const GPtrArray, num: usize) -> Vec<T>

source§

unsafe fn from_glib_container_num_as_vec( _: *const GPtrArray, _: usize, ) -> Vec<T>

source§

unsafe fn from_glib_full_num_as_vec(_: *const GPtrArray, _: usize) -> Vec<T>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

source§

unsafe fn from_glib_none_num_as_vec(ptr: *const GSList, num: usize) -> Vec<T>

source§

unsafe fn from_glib_container_num_as_vec(_: *const GSList, _: usize) -> Vec<T>

source§

unsafe fn from_glib_full_num_as_vec(_: *const GSList, _: usize) -> Vec<T>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

source§

unsafe fn from_glib_none_num_as_vec(ptr: *mut GList, num: usize) -> Vec<T>

source§

unsafe fn from_glib_container_num_as_vec(ptr: *mut GList, num: usize) -> Vec<T>

source§

unsafe fn from_glib_full_num_as_vec(ptr: *mut GList, num: usize) -> Vec<T>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

source§

unsafe fn from_glib_none_num_as_vec(ptr: *mut GPtrArray, num: usize) -> Vec<T>

source§

unsafe fn from_glib_container_num_as_vec( ptr: *mut GPtrArray, num: usize, ) -> Vec<T>

source§

unsafe fn from_glib_full_num_as_vec(ptr: *mut GPtrArray, num: usize) -> Vec<T>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

source§

unsafe fn from_glib_none_num_as_vec(ptr: *mut GSList, num: usize) -> Vec<T>

source§

unsafe fn from_glib_container_num_as_vec(ptr: *mut GSList, num: usize) -> Vec<T>

source§

unsafe fn from_glib_full_num_as_vec(ptr: *mut GSList, num: usize) -> Vec<T>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

source§

unsafe fn from_glib_none_as_vec(ptr: *const GList) -> Vec<T>

source§

unsafe fn from_glib_container_as_vec(_: *const GList) -> Vec<T>

source§

unsafe fn from_glib_full_as_vec(_: *const GList) -> Vec<T>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

source§

unsafe fn from_glib_none_as_vec(ptr: *const GPtrArray) -> Vec<T>

source§

unsafe fn from_glib_container_as_vec(_: *const GPtrArray) -> Vec<T>

source§

unsafe fn from_glib_full_as_vec(_: *const GPtrArray) -> Vec<T>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

source§

unsafe fn from_glib_none_as_vec(ptr: *const GSList) -> Vec<T>

source§

unsafe fn from_glib_container_as_vec(_: *const GSList) -> Vec<T>

source§

unsafe fn from_glib_full_as_vec(_: *const GSList) -> Vec<T>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GList) -> Vec<T>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GList) -> Vec<T>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GList) -> Vec<T>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GPtrArray) -> Vec<T>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GPtrArray) -> Vec<T>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GPtrArray) -> Vec<T>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GSList) -> Vec<T>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GSList) -> Vec<T>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GSList) -> Vec<T>

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoClosureReturnValue for T
where T: Into<Value>,

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
source§

impl<T> Property for T
where T: HasParamSpec,

§

type Value = T

source§

impl<T> PropertyGet for T
where T: HasParamSpec,

§

type Value = T

source§

fn get<R, F>(&self, f: F) -> R
where F: Fn(&<T as PropertyGet>::Value) -> R,

source§

impl<T> StaticTypeExt for T
where T: StaticType,

source§

fn ensure_type()

Ensures that the type has been registered with the type system.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToSendValue for T
where T: Send + ToValue + ?Sized,

source§

fn to_send_value(&self) -> SendValue

Returns a SendValue clone of self.
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T> TransparentType for T

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T> TryFromClosureReturnValue for T
where T: for<'a> FromValue<'a> + StaticType + 'static,

source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<'a, T, C, E> FromValueOptional<'a> for T
where T: FromValue<'a, Checker = C>, C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError<E>>, E: Error + Send + 'static,