1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use ffi;
use glib;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::mem;
use std::ptr;

glib_wrapper! {
    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct DateTime(Shared<ffi::GstDateTime>);

    match fn {
        ref => |ptr| ffi::gst_date_time_ref(ptr),
        unref => |ptr| ffi::gst_date_time_unref(ptr),
        get_type => || ffi::gst_date_time_get_type(),
    }
}

impl DateTime {
    pub fn new(tzoffset: f32, year: i32, month: i32, day: i32, hour: i32, minute: i32, seconds: f64) -> DateTime {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gst_date_time_new(tzoffset, year, month, day, hour, minute, seconds))
        }
    }

    pub fn new_from_g_date_time(dt: &glib::DateTime) -> DateTime {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gst_date_time_new_from_g_date_time(dt.to_glib_full()))
        }
    }

    pub fn new_from_iso8601_string(string: &str) -> DateTime {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gst_date_time_new_from_iso8601_string(string.to_glib_none().0))
        }
    }

    pub fn new_from_unix_epoch_local_time(secs: i64) -> DateTime {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gst_date_time_new_from_unix_epoch_local_time(secs))
        }
    }

    pub fn new_from_unix_epoch_utc(secs: i64) -> DateTime {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gst_date_time_new_from_unix_epoch_utc(secs))
        }
    }

    pub fn new_local_time(year: i32, month: i32, day: i32, hour: i32, minute: i32, seconds: f64) -> DateTime {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gst_date_time_new_local_time(year, month, day, hour, minute, seconds))
        }
    }

    pub fn new_now_local_time() -> DateTime {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gst_date_time_new_now_local_time())
        }
    }

    pub fn new_now_utc() -> DateTime {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gst_date_time_new_now_utc())
        }
    }

    pub fn new_y(year: i32) -> DateTime {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gst_date_time_new_y(year))
        }
    }

    pub fn new_ym(year: i32, month: i32) -> DateTime {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gst_date_time_new_ym(year, month))
        }
    }

    pub fn new_ymd(year: i32, month: i32, day: i32) -> DateTime {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gst_date_time_new_ymd(year, month, day))
        }
    }

    pub fn get_day(&self) -> i32 {
        unsafe {
            ffi::gst_date_time_get_day(self.to_glib_none().0)
        }
    }

    pub fn get_hour(&self) -> i32 {
        unsafe {
            ffi::gst_date_time_get_hour(self.to_glib_none().0)
        }
    }

    pub fn get_microsecond(&self) -> i32 {
        unsafe {
            ffi::gst_date_time_get_microsecond(self.to_glib_none().0)
        }
    }

    pub fn get_minute(&self) -> i32 {
        unsafe {
            ffi::gst_date_time_get_minute(self.to_glib_none().0)
        }
    }

    pub fn get_month(&self) -> i32 {
        unsafe {
            ffi::gst_date_time_get_month(self.to_glib_none().0)
        }
    }

    pub fn get_second(&self) -> i32 {
        unsafe {
            ffi::gst_date_time_get_second(self.to_glib_none().0)
        }
    }

    pub fn get_time_zone_offset(&self) -> f32 {
        unsafe {
            ffi::gst_date_time_get_time_zone_offset(self.to_glib_none().0)
        }
    }

    pub fn get_year(&self) -> i32 {
        unsafe {
            ffi::gst_date_time_get_year(self.to_glib_none().0)
        }
    }

    pub fn has_day(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_date_time_has_day(self.to_glib_none().0))
        }
    }

    pub fn has_month(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_date_time_has_month(self.to_glib_none().0))
        }
    }

    pub fn has_second(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_date_time_has_second(self.to_glib_none().0))
        }
    }

    pub fn has_time(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_date_time_has_time(self.to_glib_none().0))
        }
    }

    pub fn has_year(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_date_time_has_year(self.to_glib_none().0))
        }
    }

    pub fn to_g_date_time(&self) -> Option<glib::DateTime> {
        unsafe {
            from_glib_full(ffi::gst_date_time_to_g_date_time(self.to_glib_none().0))
        }
    }

    pub fn to_iso8601_string(&self) -> Option<String> {
        unsafe {
            from_glib_full(ffi::gst_date_time_to_iso8601_string(self.to_glib_none().0))
        }
    }
}

unsafe impl Send for DateTime {}
unsafe impl Sync for DateTime {}