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