2018-04-23 17:34:22 +00:00
|
|
|
// This file was generated by gir (https://github.com/gtk-rs/gir)
|
|
|
|
// from gir-files (https://github.com/gtk-rs/gir-files)
|
2017-07-29 14:11:44 +00:00
|
|
|
// DO NOT EDIT
|
|
|
|
|
|
|
|
use glib::translate::*;
|
|
|
|
|
2020-12-17 22:34:53 +00:00
|
|
|
glib::wrapper! {
|
2019-08-21 09:06:03 +00:00
|
|
|
#[derive()]
|
2020-11-21 13:46:33 +00:00
|
|
|
pub struct DateTime(Shared<ffi::GstDateTime>);
|
2017-07-29 14:11:44 +00:00
|
|
|
|
|
|
|
match fn {
|
2020-11-21 13:46:33 +00:00
|
|
|
ref => |ptr| ffi::gst_date_time_ref(ptr),
|
|
|
|
unref => |ptr| ffi::gst_date_time_unref(ptr),
|
|
|
|
get_type => || ffi::gst_date_time_get_type(),
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl DateTime {
|
2020-12-08 13:00:17 +00:00
|
|
|
#[doc(alias = "gst_date_time_new_from_g_date_time")]
|
2020-11-28 11:25:15 +00:00
|
|
|
pub fn from_g_date_time(dt: &glib::DateTime) -> DateTime {
|
2017-08-02 08:39:37 +00:00
|
|
|
assert_initialized_main_thread!();
|
2020-11-28 11:25:15 +00:00
|
|
|
unsafe { from_glib_full(ffi::gst_date_time_new_from_g_date_time(dt.to_glib_full())) }
|
2017-08-02 08:39:37 +00:00
|
|
|
}
|
2017-07-29 14:11:44 +00:00
|
|
|
|
2020-12-08 13:00:17 +00:00
|
|
|
#[doc(alias = "gst_date_time_new_from_iso8601_string")]
|
2020-06-11 10:27:43 +00:00
|
|
|
pub fn from_iso8601_string(string: &str) -> Result<DateTime, glib::BoolError> {
|
2017-07-29 14:11:44 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
unsafe {
|
2020-11-21 13:46:33 +00:00
|
|
|
Option::<_>::from_glib_full(ffi::gst_date_time_new_from_iso8601_string(
|
2019-06-18 10:12:00 +00:00
|
|
|
string.to_glib_none().0,
|
|
|
|
))
|
2020-12-17 22:34:53 +00:00
|
|
|
.ok_or_else(|| glib::bool_error!("Failed to create DateTime from ISO-8601 string"))
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-08 13:00:17 +00:00
|
|
|
#[doc(alias = "gst_date_time_new_from_unix_epoch_local_time")]
|
2020-12-06 10:29:12 +00:00
|
|
|
pub fn from_unix_epoch_local_time(secs: i64) -> Result<DateTime, glib::BoolError> {
|
2017-07-29 14:11:44 +00:00
|
|
|
assert_initialized_main_thread!();
|
2020-12-06 10:29:12 +00:00
|
|
|
unsafe {
|
|
|
|
Option::<_>::from_glib_full(ffi::gst_date_time_new_from_unix_epoch_local_time(secs))
|
2020-12-17 22:34:53 +00:00
|
|
|
.ok_or_else(|| glib::bool_error!("Can't create DateTime from UNIX epoch"))
|
2020-12-06 10:29:12 +00:00
|
|
|
}
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
2020-11-27 13:37:24 +00:00
|
|
|
#[cfg(any(feature = "v1_18", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
|
2020-12-08 13:00:17 +00:00
|
|
|
#[doc(alias = "gst_date_time_new_from_unix_epoch_local_time_usecs")]
|
2020-12-06 10:29:12 +00:00
|
|
|
pub fn from_unix_epoch_local_time_usecs(usecs: i64) -> Result<DateTime, glib::BoolError> {
|
2020-04-30 16:51:41 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
unsafe {
|
2020-12-06 10:29:12 +00:00
|
|
|
Option::<_>::from_glib_full(ffi::gst_date_time_new_from_unix_epoch_local_time_usecs(
|
2020-04-30 16:51:41 +00:00
|
|
|
usecs,
|
|
|
|
))
|
2020-12-17 22:34:53 +00:00
|
|
|
.ok_or_else(|| glib::bool_error!("Can't create DateTime from UNIX epoch"))
|
2020-04-30 16:51:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-08 13:00:17 +00:00
|
|
|
#[doc(alias = "gst_date_time_new_from_unix_epoch_utc")]
|
2020-12-06 10:29:12 +00:00
|
|
|
pub fn from_unix_epoch_utc(secs: i64) -> Result<DateTime, glib::BoolError> {
|
2017-07-29 14:11:44 +00:00
|
|
|
assert_initialized_main_thread!();
|
2020-12-06 10:29:12 +00:00
|
|
|
unsafe {
|
|
|
|
Option::<_>::from_glib_full(ffi::gst_date_time_new_from_unix_epoch_utc(secs))
|
2020-12-17 22:34:53 +00:00
|
|
|
.ok_or_else(|| glib::bool_error!("Can't create DateTime from UNIX epoch"))
|
2020-12-06 10:29:12 +00:00
|
|
|
}
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
2020-11-27 13:37:24 +00:00
|
|
|
#[cfg(any(feature = "v1_18", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
|
2020-12-08 13:00:17 +00:00
|
|
|
#[doc(alias = "gst_date_time_new_from_unix_epoch_utc_usecs")]
|
2020-12-06 10:29:12 +00:00
|
|
|
pub fn from_unix_epoch_utc_usecs(usecs: i64) -> Result<DateTime, glib::BoolError> {
|
2017-07-29 14:11:44 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
unsafe {
|
2020-12-06 10:29:12 +00:00
|
|
|
Option::<_>::from_glib_full(ffi::gst_date_time_new_from_unix_epoch_utc_usecs(usecs))
|
2020-12-17 22:34:53 +00:00
|
|
|
.ok_or_else(|| glib::bool_error!("Can't create DateTime from UNIX epoch"))
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-08 13:00:17 +00:00
|
|
|
#[doc(alias = "gst_date_time_new_now_local_time")]
|
2017-07-29 14:11:44 +00:00
|
|
|
pub fn new_now_local_time() -> DateTime {
|
|
|
|
assert_initialized_main_thread!();
|
2020-11-21 13:46:33 +00:00
|
|
|
unsafe { from_glib_full(ffi::gst_date_time_new_now_local_time()) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
2020-12-08 13:00:17 +00:00
|
|
|
#[doc(alias = "gst_date_time_new_now_utc")]
|
2017-07-29 14:11:44 +00:00
|
|
|
pub fn new_now_utc() -> DateTime {
|
|
|
|
assert_initialized_main_thread!();
|
2020-11-21 13:46:33 +00:00
|
|
|
unsafe { from_glib_full(ffi::gst_date_time_new_now_utc()) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
2020-12-08 13:00:17 +00:00
|
|
|
#[doc(alias = "gst_date_time_get_year")]
|
2017-07-29 14:11:44 +00:00
|
|
|
pub fn get_year(&self) -> i32 {
|
2020-11-21 13:46:33 +00:00
|
|
|
unsafe { ffi::gst_date_time_get_year(self.to_glib_none().0) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
2020-12-08 13:00:17 +00:00
|
|
|
#[doc(alias = "gst_date_time_has_day")]
|
2017-07-29 14:11:44 +00:00
|
|
|
pub fn has_day(&self) -> bool {
|
2020-11-21 13:46:33 +00:00
|
|
|
unsafe { from_glib(ffi::gst_date_time_has_day(self.to_glib_none().0)) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
2020-12-08 13:00:17 +00:00
|
|
|
#[doc(alias = "gst_date_time_has_month")]
|
2017-07-29 14:11:44 +00:00
|
|
|
pub fn has_month(&self) -> bool {
|
2020-11-21 13:46:33 +00:00
|
|
|
unsafe { from_glib(ffi::gst_date_time_has_month(self.to_glib_none().0)) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
2020-12-08 13:00:17 +00:00
|
|
|
#[doc(alias = "gst_date_time_has_second")]
|
2017-07-29 14:11:44 +00:00
|
|
|
pub fn has_second(&self) -> bool {
|
2020-11-21 13:46:33 +00:00
|
|
|
unsafe { from_glib(ffi::gst_date_time_has_second(self.to_glib_none().0)) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
2020-12-08 13:00:17 +00:00
|
|
|
#[doc(alias = "gst_date_time_has_time")]
|
2017-07-29 14:11:44 +00:00
|
|
|
pub fn has_time(&self) -> bool {
|
2020-11-21 13:46:33 +00:00
|
|
|
unsafe { from_glib(ffi::gst_date_time_has_time(self.to_glib_none().0)) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
2020-12-08 13:00:17 +00:00
|
|
|
#[doc(alias = "gst_date_time_has_year")]
|
2017-07-29 14:11:44 +00:00
|
|
|
pub fn has_year(&self) -> bool {
|
2020-11-21 13:46:33 +00:00
|
|
|
unsafe { from_glib(ffi::gst_date_time_has_year(self.to_glib_none().0)) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
2020-12-08 13:00:17 +00:00
|
|
|
#[doc(alias = "gst_date_time_to_g_date_time")]
|
2019-12-17 19:00:42 +00:00
|
|
|
pub fn to_g_date_time(&self) -> Result<glib::DateTime, glib::BoolError> {
|
|
|
|
unsafe {
|
2020-11-21 13:46:33 +00:00
|
|
|
Option::<_>::from_glib_full(ffi::gst_date_time_to_g_date_time(self.to_glib_none().0))
|
2020-12-17 22:34:53 +00:00
|
|
|
.ok_or_else(|| glib::bool_error!("Can't create glib::DateTime from DateTime"))
|
2019-12-17 19:00:42 +00:00
|
|
|
}
|
2017-08-02 08:39:37 +00:00
|
|
|
}
|
2017-07-29 14:11:44 +00:00
|
|
|
|
2020-12-08 13:00:17 +00:00
|
|
|
#[doc(alias = "gst_date_time_to_iso8601_string")]
|
2020-11-21 13:46:33 +00:00
|
|
|
pub fn to_iso8601_string(&self) -> Result<glib::GString, glib::BoolError> {
|
2017-07-29 14:11:44 +00:00
|
|
|
unsafe {
|
2020-11-21 13:46:33 +00:00
|
|
|
Option::<_>::from_glib_full(ffi::gst_date_time_to_iso8601_string(self.to_glib_none().0))
|
2020-12-17 22:34:53 +00:00
|
|
|
.ok_or_else(|| glib::bool_error!("Failed to create ISO-8601 string from DateTime"))
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe impl Send for DateTime {}
|
2017-12-18 07:42:27 +00:00
|
|
|
unsafe impl Sync for DateTime {}
|