Skip to content

Commit

Permalink
Hide CustomTimeZone::{gmt, bst} (unicode-org#5495)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian authored Sep 5, 2024
1 parent 901390e commit d2c6e9c
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 102 deletions.
14 changes: 6 additions & 8 deletions components/timezone/src/time_zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,29 +102,27 @@ impl CustomTimeZone {
/// All other fields are left empty.
pub const fn utc() -> Self {
Self {
gmt_offset: Some(GmtOffset::utc()),
gmt_offset: Some(GmtOffset::zero()),
time_zone_id: None,
metazone_id: None,
zone_variant: None,
}
}

/// Creates a new [`CustomTimeZone`] representing Greenwich Mean Time
/// (London Time as observed in the winter).
#[doc(hidden)] // unstable, test-only
pub const fn gmt() -> Self {
Self {
gmt_offset: Some(GmtOffset::utc()),
gmt_offset: Some(GmtOffset::zero()),
time_zone_id: Some(TimeZoneBcp47Id(tinystr!(8, "gblon"))),
metazone_id: Some(MetazoneId(tinystr!(4, "mgmt"))),
zone_variant: Some(ZoneVariant::standard()),
}
}

/// Creates a new [`CustomTimeZone`] representing British Summer Time
/// (London Time as observed in the summer).
#[doc(hidden)] // unstable, test-only
pub const fn bst() -> Self {
Self {
gmt_offset: Some(GmtOffset::utc_plus_1()),
gmt_offset: Some(GmtOffset::from_offset_eighths_of_hour(8)),
time_zone_id: Some(TimeZoneBcp47Id(tinystr!(8, "gblon"))),
metazone_id: Some(MetazoneId(tinystr!(4, "mgmt"))),
zone_variant: Some(ZoneVariant::daylight()),
Expand Down Expand Up @@ -192,7 +190,7 @@ impl CustomTimeZone {
Err(UnknownTimeZoneError)
}

/// Overwrite the metazone id in MockTimeZone.
/// Overwrite the metazone ID.
///
/// # Examples
///
Expand Down
10 changes: 3 additions & 7 deletions components/timezone/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct GmtOffset(i32);

impl Default for GmtOffset {
fn default() -> Self {
Self::utc()
Self::zero()
}
}

Expand Down Expand Up @@ -52,15 +52,11 @@ impl GmtOffset {
Self(eighths_of_hour as i32 * 450)
}

/// Creates a [`GmtOffset`] at UTC.
pub const fn utc() -> Self {
/// Creates a [`GmtOffset`] of 0.
pub const fn zero() -> Self {
Self(0)
}

pub(crate) const fn utc_plus_1() -> Self {
Self(3600)
}

/// Parse a [`GmtOffset`] from bytes.
///
/// The offset must range from GMT-12 to GMT+14.
Expand Down
4 changes: 0 additions & 4 deletions ffi/capi/bindings/c/CustomTimeZone.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions ffi/capi/bindings/cpp/icu4x/CustomTimeZone.d.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions ffi/capi/bindings/cpp/icu4x/CustomTimeZone.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 0 additions & 26 deletions ffi/capi/bindings/dart/CustomTimeZone.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions ffi/capi/bindings/js/CustomTimeZone.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 0 additions & 20 deletions ffi/capi/bindings/js/CustomTimeZone.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 1 addition & 15 deletions ffi/capi/src/timezone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,12 @@ pub mod ffi {

/// Creates a time zone for UTC (Coordinated Universal Time).
#[diplomat::rust_link(icu::timezone::CustomTimeZone::utc, FnInStruct)]
#[diplomat::rust_link(icu::timezone::GmtOffset::utc, FnInStruct, hidden)]
#[diplomat::rust_link(icu::timezone::GmtOffset::zero, FnInStruct, hidden)]
#[diplomat::attr(supports = fallible_constructors, named_constructor)]
pub fn utc() -> Box<CustomTimeZone> {
Box::new(icu_timezone::CustomTimeZone::utc().into())
}

/// Creates a time zone for GMT (London winter time).
#[diplomat::rust_link(icu::timezone::CustomTimeZone::gmt, FnInStruct)]
#[diplomat::attr(supports = fallible_constructors, named_constructor)]
pub fn gmt() -> Box<CustomTimeZone> {
Box::new(icu_timezone::CustomTimeZone::gmt().into())
}

/// Creates a time zone for BST (London summer time).
#[diplomat::rust_link(icu::timezone::CustomTimeZone::bst, FnInStruct)]
#[diplomat::attr(supports = fallible_constructors, named_constructor)]
pub fn bst() -> Box<CustomTimeZone> {
Box::new(icu_timezone::CustomTimeZone::bst().into())
}

/// Sets the `gmt_offset` field from offset seconds.
///
/// Errors if the offset seconds are out of range.
Expand Down

0 comments on commit d2c6e9c

Please sign in to comment.