spinoso_time/time/tzrs/
build.rs

1use super::{Offset, Result, Time};
2
3impl Time {
4    /// Returns a Time based on the provided values in the local timezone.
5    ///
6    /// Can be used to implement Ruby [`Time#local`], [`Time#mktime`].
7    ///
8    /// # Errors
9    ///
10    /// Can produce a [`TimeError`], generally when provided values are out of
11    /// range.
12    ///
13    /// [`Time#local`]: https://ruby-doc.org/core-3.1.2/Time.html#method-c-local
14    /// [`Time#mktime`]: https://ruby-doc.org/core-3.1.2/Time.html#method-c-mktime
15    /// [`TimeError`]: super::TimeError
16    #[inline]
17    pub fn local(
18        year: i32,
19        month: u8,
20        month_day: u8,
21        hour: u8,
22        minute: u8,
23        second: u8,
24        nanoseconds: u32,
25    ) -> Result<Self> {
26        Time::new(
27            year,
28            month,
29            month_day,
30            hour,
31            minute,
32            second,
33            nanoseconds,
34            Offset::local(),
35        )
36    }
37
38    /// Returns a Time based on the provided values in UTC.
39    ///
40    /// Can be used to implement Ruby [`Time#utc`], [`Time#gm`].
41    ///
42    /// # Errors
43    ///
44    /// Can produce a [`TimeError`], generally when provided values are out of
45    /// range.
46    ///
47    /// [`Time#utc`]: https://ruby-doc.org/core-3.1.2/Time.html#method-c-utc
48    /// [`Time#gm`]: https://ruby-doc.org/core-3.1.2/Time.html#method-c-gm
49    /// [`TimeError`]: super::TimeError
50    #[inline]
51    pub fn utc(
52        year: i32,
53        month: u8,
54        month_day: u8,
55        hour: u8,
56        minute: u8,
57        second: u8,
58        nanoseconds: u32,
59    ) -> Result<Self> {
60        Time::new(year, month, month_day, hour, minute, second, nanoseconds, Offset::utc())
61    }
62}