rust_icu_ucal

Struct UCalendar

Source
pub struct UCalendar { /* private fields */ }
Expand description

Implements the UCalendar type from ucal.h.

The naming rust_icu_ucal::UCalendar is a bit repetetetitive, but makes it a bit more obvious what ICU type it is wrapping.

Implementations§

Source§

impl UCalendar

Source

pub fn new( zone_id: &str, locale: &str, cal_type: UCalendarType, ) -> Result<UCalendar, Error>

Creates a new UCalendar.

Implements ucal_open.

Source

pub fn as_c_calendar(&self) -> *const UCalendar

Returns this UCalendar’s internal C representation. Use only for interfacing with the C low-level API.

Source

pub fn set_millis(&mut self, date_time: UDate) -> Result<(), Error>

Sets the calendar’s current date/time in milliseconds since the epoch.

Implements ucal_setMillis.

Source

pub fn get_millis(&self) -> Result<UDate, Error>

Gets the calendar’s current date/time in milliseconds since the epoch.

Implements ucal_getMillis.

Source

pub fn set_date( &mut self, year: i32, month: i32, date: i32, ) -> Result<(), Error>

Sets the calendar’s current date in the calendar’s local time zone.

Note that month is 0-based.

Implements ucal_setDate.

Source

pub fn set_date_time( &mut self, year: i32, month: i32, date: i32, hour: i32, minute: i32, second: i32, ) -> Result<(), Error>

Sets the calendar’s current date and time in the calendar’s local time zone.

Note that month is 0-based.

Implements ucal_setDateTime.

Source

pub fn get_zone_offset(&self) -> Result<i32, Error>

Returns the calendar’s time zone’s offset from UTC in milliseconds, for the calendar’s current date/time.

This does not include the daylight savings offset, if any. Note that the calendar’s current date/time is significant because time zones are occasionally redefined – a time zone that has a +16.5 hour offset today might have had a +17 hour offset a decade ago.

Wraps ucal_get for UCAL_ZONE_OFFSET.

Source

pub fn get_dst_offset(&self) -> Result<i32, Error>

Returns the calendar’s daylight savings offset from its non-DST time, in milliseconds, for the calendar’s current date/time. This may be 0 if the time zone does not observe DST at all, or if the time zone is not in the daylight savings period at the calendar’s current date/time.

Wraps ucal_get for UCAL_ZONE_DST_OFFSET.

Source

pub fn in_daylight_time(&self) -> Result<bool, Error>

Returns true if the calendar is currently in daylight savings / summer time.

Implements ucal_inDaylightTime.

Source

pub fn get(&self, field: UCalendarDateFields) -> Result<i32, Error>

Implements ucal_get.

Consider using specific higher-level methods instead.

Trait Implementations§

Source§

impl Debug for UCalendar

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for UCalendar

Source§

fn drop(&mut self)

Deallocates the internal representation of UCalendar.

Implements ucal_close.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.