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
|
|
|
|
|
2017-08-02 08:39:37 +00:00
|
|
|
use glib;
|
2017-07-29 14:11:44 +00:00
|
|
|
use glib::translate::*;
|
2019-06-18 10:12:00 +00:00
|
|
|
use glib::GString;
|
2019-03-19 07:40:05 +00:00
|
|
|
use gst_sys;
|
2017-07-29 14:11:44 +00:00
|
|
|
|
|
|
|
glib_wrapper! {
|
2019-08-21 09:06:03 +00:00
|
|
|
#[derive()]
|
2019-03-19 07:40:05 +00:00
|
|
|
pub struct DateTime(Shared<gst_sys::GstDateTime>);
|
2017-07-29 14:11:44 +00:00
|
|
|
|
|
|
|
match fn {
|
2019-03-19 07:40:05 +00:00
|
|
|
ref => |ptr| gst_sys::gst_date_time_ref(ptr),
|
|
|
|
unref => |ptr| gst_sys::gst_date_time_unref(ptr),
|
|
|
|
get_type => || gst_sys::gst_date_time_get_type(),
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl DateTime {
|
2019-06-18 10:12:00 +00:00
|
|
|
pub fn new(
|
|
|
|
tzoffset: f32,
|
|
|
|
year: i32,
|
|
|
|
month: i32,
|
|
|
|
day: i32,
|
|
|
|
hour: i32,
|
|
|
|
minute: i32,
|
|
|
|
seconds: f64,
|
2020-03-22 10:23:16 +00:00
|
|
|
) -> Result<DateTime, glib::BoolError> {
|
2017-07-29 14:11:44 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
unsafe {
|
2020-03-22 10:23:16 +00:00
|
|
|
Option::<_>::from_glib_full(gst_sys::gst_date_time_new(
|
2019-06-18 10:12:00 +00:00
|
|
|
tzoffset, year, month, day, hour, minute, seconds,
|
|
|
|
))
|
2020-03-22 10:23:16 +00:00
|
|
|
.ok_or_else(|| glib_bool_error!("Can't create DateTime"))
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-22 10:23:16 +00:00
|
|
|
pub fn new_from_g_date_time(dt: &glib::DateTime) -> Result<DateTime, glib::BoolError> {
|
2017-08-02 08:39:37 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
unsafe {
|
2020-03-22 10:23:16 +00:00
|
|
|
Option::<_>::from_glib_full(gst_sys::gst_date_time_new_from_g_date_time(
|
2019-06-18 10:12:00 +00:00
|
|
|
dt.to_glib_full(),
|
|
|
|
))
|
2020-03-22 10:23:16 +00:00
|
|
|
.ok_or_else(|| glib_bool_error!("Can't create DateTime from glib::DateTime"))
|
2017-08-02 08:39:37 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-29 14:11:44 +00:00
|
|
|
|
2019-12-17 19:00:42 +00:00
|
|
|
pub fn new_from_iso8601_string(string: &str) -> Result<DateTime, glib::BoolError> {
|
2017-07-29 14:11:44 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
unsafe {
|
2019-12-17 19:00:42 +00:00
|
|
|
Option::<_>::from_glib_full(gst_sys::gst_date_time_new_from_iso8601_string(
|
2019-06-18 10:12:00 +00:00
|
|
|
string.to_glib_none().0,
|
|
|
|
))
|
2019-12-17 19:00:42 +00:00
|
|
|
.ok_or_else(|| glib_bool_error!("Failed to create DateTime from ISO-8601 string"))
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn new_from_unix_epoch_local_time(secs: i64) -> DateTime {
|
|
|
|
assert_initialized_main_thread!();
|
2019-06-18 10:12:00 +00:00
|
|
|
unsafe { from_glib_full(gst_sys::gst_date_time_new_from_unix_epoch_local_time(secs)) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn new_from_unix_epoch_utc(secs: i64) -> DateTime {
|
|
|
|
assert_initialized_main_thread!();
|
2019-06-18 10:12:00 +00:00
|
|
|
unsafe { from_glib_full(gst_sys::gst_date_time_new_from_unix_epoch_utc(secs)) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
2019-06-18 10:12:00 +00:00
|
|
|
pub fn new_local_time(
|
|
|
|
year: i32,
|
|
|
|
month: i32,
|
|
|
|
day: i32,
|
|
|
|
hour: i32,
|
|
|
|
minute: i32,
|
|
|
|
seconds: f64,
|
|
|
|
) -> DateTime {
|
2017-07-29 14:11:44 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
unsafe {
|
2019-06-18 10:12:00 +00:00
|
|
|
from_glib_full(gst_sys::gst_date_time_new_local_time(
|
|
|
|
year, month, day, hour, minute, seconds,
|
|
|
|
))
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn new_now_local_time() -> DateTime {
|
|
|
|
assert_initialized_main_thread!();
|
2019-06-18 10:12:00 +00:00
|
|
|
unsafe { from_glib_full(gst_sys::gst_date_time_new_now_local_time()) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn new_now_utc() -> DateTime {
|
|
|
|
assert_initialized_main_thread!();
|
2019-06-18 10:12:00 +00:00
|
|
|
unsafe { from_glib_full(gst_sys::gst_date_time_new_now_utc()) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
2020-03-22 10:23:16 +00:00
|
|
|
pub fn new_y(year: i32) -> Result<DateTime, glib::BoolError> {
|
2017-07-29 14:11:44 +00:00
|
|
|
assert_initialized_main_thread!();
|
2020-03-22 10:23:16 +00:00
|
|
|
unsafe {
|
|
|
|
Option::<_>::from_glib_full(gst_sys::gst_date_time_new_y(year))
|
|
|
|
.ok_or_else(|| glib_bool_error!("Can't create DateTime"))
|
|
|
|
}
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
2020-03-22 10:23:16 +00:00
|
|
|
pub fn new_ym(year: i32, month: i32) -> Result<DateTime, glib::BoolError> {
|
2017-07-29 14:11:44 +00:00
|
|
|
assert_initialized_main_thread!();
|
2020-03-22 10:23:16 +00:00
|
|
|
unsafe {
|
|
|
|
Option::<_>::from_glib_full(gst_sys::gst_date_time_new_ym(year, month))
|
|
|
|
.ok_or_else(|| glib_bool_error!("Can't create DateTime"))
|
|
|
|
}
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
2020-03-22 10:23:16 +00:00
|
|
|
pub fn new_ymd(year: i32, month: i32, day: i32) -> Result<DateTime, glib::BoolError> {
|
2017-07-29 14:11:44 +00:00
|
|
|
assert_initialized_main_thread!();
|
2020-03-22 10:23:16 +00:00
|
|
|
unsafe {
|
|
|
|
Option::<_>::from_glib_full(gst_sys::gst_date_time_new_ymd(year, month, day))
|
|
|
|
.ok_or_else(|| glib_bool_error!("Can't create DateTime"))
|
|
|
|
}
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_day(&self) -> i32 {
|
2019-06-18 10:12:00 +00:00
|
|
|
unsafe { gst_sys::gst_date_time_get_day(self.to_glib_none().0) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_hour(&self) -> i32 {
|
2019-06-18 10:12:00 +00:00
|
|
|
unsafe { gst_sys::gst_date_time_get_hour(self.to_glib_none().0) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_microsecond(&self) -> i32 {
|
2019-06-18 10:12:00 +00:00
|
|
|
unsafe { gst_sys::gst_date_time_get_microsecond(self.to_glib_none().0) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_minute(&self) -> i32 {
|
2019-06-18 10:12:00 +00:00
|
|
|
unsafe { gst_sys::gst_date_time_get_minute(self.to_glib_none().0) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_month(&self) -> i32 {
|
2019-06-18 10:12:00 +00:00
|
|
|
unsafe { gst_sys::gst_date_time_get_month(self.to_glib_none().0) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_second(&self) -> i32 {
|
2019-06-18 10:12:00 +00:00
|
|
|
unsafe { gst_sys::gst_date_time_get_second(self.to_glib_none().0) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_time_zone_offset(&self) -> f32 {
|
2019-06-18 10:12:00 +00:00
|
|
|
unsafe { gst_sys::gst_date_time_get_time_zone_offset(self.to_glib_none().0) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_year(&self) -> i32 {
|
2019-06-18 10:12:00 +00:00
|
|
|
unsafe { gst_sys::gst_date_time_get_year(self.to_glib_none().0) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn has_day(&self) -> bool {
|
2019-06-18 10:12:00 +00:00
|
|
|
unsafe { from_glib(gst_sys::gst_date_time_has_day(self.to_glib_none().0)) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn has_month(&self) -> bool {
|
2019-06-18 10:12:00 +00:00
|
|
|
unsafe { from_glib(gst_sys::gst_date_time_has_month(self.to_glib_none().0)) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn has_second(&self) -> bool {
|
2019-06-18 10:12:00 +00:00
|
|
|
unsafe { from_glib(gst_sys::gst_date_time_has_second(self.to_glib_none().0)) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn has_time(&self) -> bool {
|
2019-06-18 10:12:00 +00:00
|
|
|
unsafe { from_glib(gst_sys::gst_date_time_has_time(self.to_glib_none().0)) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn has_year(&self) -> bool {
|
2019-06-18 10:12:00 +00:00
|
|
|
unsafe { from_glib(gst_sys::gst_date_time_has_year(self.to_glib_none().0)) }
|
2017-07-29 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
2019-12-17 19:00:42 +00:00
|
|
|
pub fn to_g_date_time(&self) -> Result<glib::DateTime, glib::BoolError> {
|
|
|
|
unsafe {
|
|
|
|
Option::<_>::from_glib_full(gst_sys::gst_date_time_to_g_date_time(
|
|
|
|
self.to_glib_none().0,
|
|
|
|
))
|
|
|
|
.ok_or_else(|| glib_bool_error!("Can't create glib::DateTime from DateTime"))
|
|
|
|
}
|
2017-08-02 08:39:37 +00:00
|
|
|
}
|
2017-07-29 14:11:44 +00:00
|
|
|
|
2019-12-17 19:00:42 +00:00
|
|
|
pub fn to_iso8601_string(&self) -> Result<GString, glib::BoolError> {
|
2017-07-29 14:11:44 +00:00
|
|
|
unsafe {
|
2019-12-17 19:00:42 +00:00
|
|
|
Option::<_>::from_glib_full(gst_sys::gst_date_time_to_iso8601_string(
|
2019-06-18 10:12:00 +00:00
|
|
|
self.to_glib_none().0,
|
|
|
|
))
|
2019-12-17 19:00:42 +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 {}
|