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