glib/time_zone.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use crate::translate::*;
4use crate::{TimeType, TimeZone};
5
6impl TimeZone {
7 /// Finds an interval within @self that corresponds to the given @time_,
8 /// possibly adjusting @time_ if required to fit into an interval.
9 /// The meaning of @time_ depends on @type_.
10 ///
11 /// This function is similar to g_time_zone_find_interval(), with the
12 /// difference that it always succeeds (by making the adjustments
13 /// described below).
14 ///
15 /// In any of the cases where g_time_zone_find_interval() succeeds then
16 /// this function returns the same value, without modifying @time_.
17 ///
18 /// This function may, however, modify @time_ in order to deal with
19 /// non-existent times. If the non-existent local @time_ of 02:30 were
20 /// requested on March 14th 2010 in Toronto then this function would
21 /// adjust @time_ to be 03:00 and return the interval containing the
22 /// adjusted time.
23 /// ## `type_`
24 /// the #GTimeType of @time_
25 /// ## `time_`
26 /// a pointer to a number of seconds since January 1, 1970
27 ///
28 /// # Returns
29 ///
30 /// the interval containing @time_, never -1
31 #[doc(alias = "g_time_zone_adjust_time")]
32 pub fn adjust_time(&self, type_: TimeType, mut time: i64) -> (i32, i64) {
33 unsafe {
34 let res = crate::ffi::g_time_zone_adjust_time(
35 self.to_glib_none().0,
36 type_.into_glib(),
37 &mut time,
38 );
39 (res, time)
40 }
41 }
42}