Skip to content

Commit

Permalink
Fix timezone naming convention in env_preferences (#5954)
Browse files Browse the repository at this point in the history
As decided in #4350


<!--
Thank you for your pull request to ICU4X!

Reminder: try to use [Conventional
Comments](https://conventionalcomments.org/) to make comments clearer.

Please see
https://github.com/unicode-org/icu4x/blob/main/CONTRIBUTING.md for
general
information on contributing to ICU4X.
-->
  • Loading branch information
Manishearth authored Jan 10, 2025
1 parent 6da19a2 commit e8df60b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion utils/env_preferences/src/apple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ pub fn get_system_calendars() -> Result<Vec<(String, String)>, RetrievalError> {
}

/// Get the current time zone of the system
pub fn get_system_timezone() -> Result<String, RetrievalError> {
pub fn get_system_time_zone() -> Result<String, RetrievalError> {
// SAFETY: Returns the time zone currently used by the system
// Returns an immutable reference to TimeZone object owned by us
let timezone = unsafe { timezone::CFTimeZoneCopySystem() };
Expand Down
2 changes: 1 addition & 1 deletion utils/env_preferences/src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub fn get_system_calendars() -> Result<Vec<(String, String)>, RetrievalError> {
}

/// Get the current time zone of the system
pub fn get_system_timezone() -> Result<String, RetrievalError> {
pub fn get_system_time_zone() -> Result<String, RetrievalError> {
let calendar = Globalization::Calendar::new()?;
let timezone = calendar.GetTimeZone()?;
Ok(timezone.to_string_lossy())
Expand Down
8 changes: 4 additions & 4 deletions utils/env_preferences/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ mod linux_tests {
#[cfg(target_os = "macos")]
#[cfg(test)]
mod macos_test {
use env_preferences::{get_locales, get_system_calendars, get_system_timezone};
use env_preferences::{get_locales, get_system_calendars, get_system_time_zone};
use icu_locale::Locale;

#[test]
Expand Down Expand Up @@ -111,15 +111,15 @@ mod macos_test {

#[test]
fn test_time_zone() {
let time_zone = get_system_timezone().unwrap();
let time_zone = get_system_time_zone().unwrap();
assert!(!time_zone.is_empty(), "Couldn't retreive time_zone");
}
}

#[cfg(target_os = "windows")]
#[cfg(test)]
mod windows_test {
use env_preferences::{get_locales, get_system_calendars, get_system_timezone};
use env_preferences::{get_locales, get_system_calendars, get_system_time_zone};
use icu_locale::Locale;

#[test]
Expand Down Expand Up @@ -155,7 +155,7 @@ mod windows_test {

#[test]
fn test_time_zone() {
let time_zone = get_system_timezone().unwrap();
let time_zone = get_system_time_zone().unwrap();
assert!(!time_zone.is_empty(), "Couldn't retreive time_zone");
assert!(time_zone.is_ascii(), "Invalid TimeZone format");
}
Expand Down

0 comments on commit e8df60b

Please sign in to comment.