glib/auto/
time_zone.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{ffi, translate::*, TimeType};
6
7crate::wrapper! {
8    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
9    pub struct TimeZone(Shared<ffi::GTimeZone>);
10
11    match fn {
12        ref => |ptr| ffi::g_time_zone_ref(ptr),
13        unref => |ptr| ffi::g_time_zone_unref(ptr),
14        type_ => || ffi::g_time_zone_get_type(),
15    }
16}
17
18impl TimeZone {
19    #[cfg_attr(feature = "v2_68", deprecated = "Since 2.68")]
20    #[allow(deprecated)]
21    #[doc(alias = "g_time_zone_new")]
22    pub fn new(identifier: Option<&str>) -> TimeZone {
23        unsafe { from_glib_full(ffi::g_time_zone_new(identifier.to_glib_none().0)) }
24    }
25
26    #[cfg(feature = "v2_68")]
27    #[cfg_attr(docsrs, doc(cfg(feature = "v2_68")))]
28    #[doc(alias = "g_time_zone_new_identifier")]
29    #[doc(alias = "new_identifier")]
30    pub fn from_identifier(identifier: Option<&str>) -> Option<TimeZone> {
31        unsafe { from_glib_full(ffi::g_time_zone_new_identifier(identifier.to_glib_none().0)) }
32    }
33
34    #[doc(alias = "g_time_zone_new_local")]
35    #[doc(alias = "new_local")]
36    pub fn local() -> TimeZone {
37        unsafe { from_glib_full(ffi::g_time_zone_new_local()) }
38    }
39
40    #[cfg(feature = "v2_58")]
41    #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
42    #[doc(alias = "g_time_zone_new_offset")]
43    #[doc(alias = "new_offset")]
44    pub fn from_offset(seconds: i32) -> TimeZone {
45        unsafe { from_glib_full(ffi::g_time_zone_new_offset(seconds)) }
46    }
47
48    #[doc(alias = "g_time_zone_new_utc")]
49    #[doc(alias = "new_utc")]
50    pub fn utc() -> TimeZone {
51        unsafe { from_glib_full(ffi::g_time_zone_new_utc()) }
52    }
53
54    #[doc(alias = "g_time_zone_find_interval")]
55    pub fn find_interval(&self, type_: TimeType, time_: i64) -> i32 {
56        unsafe { ffi::g_time_zone_find_interval(self.to_glib_none().0, type_.into_glib(), time_) }
57    }
58
59    #[doc(alias = "g_time_zone_get_abbreviation")]
60    #[doc(alias = "get_abbreviation")]
61    pub fn abbreviation(&self, interval: i32) -> crate::GString {
62        unsafe {
63            from_glib_none(ffi::g_time_zone_get_abbreviation(
64                self.to_glib_none().0,
65                interval,
66            ))
67        }
68    }
69
70    #[cfg(feature = "v2_58")]
71    #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
72    #[doc(alias = "g_time_zone_get_identifier")]
73    #[doc(alias = "get_identifier")]
74    pub fn identifier(&self) -> crate::GString {
75        unsafe { from_glib_none(ffi::g_time_zone_get_identifier(self.to_glib_none().0)) }
76    }
77
78    #[doc(alias = "g_time_zone_get_offset")]
79    #[doc(alias = "get_offset")]
80    pub fn offset(&self, interval: i32) -> i32 {
81        unsafe { ffi::g_time_zone_get_offset(self.to_glib_none().0, interval) }
82    }
83
84    #[doc(alias = "g_time_zone_is_dst")]
85    pub fn is_dst(&self, interval: i32) -> bool {
86        unsafe { from_glib(ffi::g_time_zone_is_dst(self.to_glib_none().0, interval)) }
87    }
88}
89
90unsafe impl Send for TimeZone {}
91unsafe impl Sync for TimeZone {}