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 ///
26 /// # Returns
27 ///
28 /// the interval containing @time_, never -1
29 ///
30 /// ## `time_`
31 /// a pointer to a number of seconds since January 1, 1970
32 // rustdoc-stripper-ignore-next-stop
33 /// Finds an interval within @self that corresponds to the given @time_,
34 /// possibly adjusting @time_ if required to fit into an interval.
35 /// The meaning of @time_ depends on @type_.
36 ///
37 /// This function is similar to g_time_zone_find_interval(), with the
38 /// difference that it always succeeds (by making the adjustments
39 /// described below).
40 ///
41 /// In any of the cases where g_time_zone_find_interval() succeeds then
42 /// this function returns the same value, without modifying @time_.
43 ///
44 /// This function may, however, modify @time_ in order to deal with
45 /// non-existent times. If the non-existent local @time_ of 02:30 were
46 /// requested on March 14th 2010 in Toronto then this function would
47 /// adjust @time_ to be 03:00 and return the interval containing the
48 /// adjusted time.
49 /// ## `type_`
50 /// the #GTimeType of @time_
51 ///
52 /// # Returns
53 ///
54 /// the interval containing @time_, never -1
55 ///
56 /// ## `time_`
57 /// a pointer to a number of seconds since January 1, 1970
58 #[doc(alias = "g_time_zone_adjust_time")]
59 pub fn adjust_time(&self, type_: TimeType, mut time: i64) -> (i32, i64) {
60 unsafe {
61 let res = crate::ffi::g_time_zone_adjust_time(
62 self.to_glib_none().0,
63 type_.into_glib(),
64 &mut time,
65 );
66 (res, time)
67 }
68 }
69}