Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions src/uu/date/src/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@

/// OHOS helper: pass through the system time zone ID returned by
/// TimeService (OH_TimeService_GetTimeZone, e.g. "Asia/Shanghai") and
/// resolve it against the embedded IANA tzdata (jiff-tzdb) so that

Check warning on line 38 in src/uu/date/src/date.rs

View workflow job for this annotation

GitHub Actions / Style/spelling (ubuntu-latest, feat_os_unix)

WARNING: `cspell`: Unknown word 'tzdb' (file:'src/uu/date/src/date.rs', line:38)
/// historial DST rules and transitions are preserved. jiff's

Check warning on line 39 in src/uu/date/src/date.rs

View workflow job for this annotation

GitHub Actions / Style/spelling (ubuntu-latest, feat_os_unix)

WARNING: `cspell`: Unknown word 'historial' (file:'src/uu/date/src/date.rs', line:39)
/// `try_system()` is useless on OHOS because both `/etc/localtime` and
/// the zoneinfo dirs are absent.

Check warning on line 41 in src/uu/date/src/date.rs

View workflow job for this annotation

GitHub Actions / Style/spelling (ubuntu-latest, feat_os_unix)

WARNING: `cspell`: Unknown word 'zoneinfo' (file:'src/uu/date/src/date.rs', line:41)
#[cfg(target_env = "ohos")]
fn ohos_system_zone() -> jiff::tz::TimeZone {
use core::ffi::{CStr, c_char};
Expand All @@ -55,7 +55,7 @@
let id = unsafe { CStr::from_ptr(buf.as_ptr() as *const c_char) }
.to_string_lossy()
.into_owned();
if let Some((name, tzif)) = jiff_tzdb::get(&id) {

Check warning on line 58 in src/uu/date/src/date.rs

View workflow job for this annotation

GitHub Actions / Style/spelling (ubuntu-latest, feat_os_unix)

WARNING: `cspell`: Unknown word 'tzif' (file:'src/uu/date/src/date.rs', line:58)
if let Ok(tz) = jiff::tz::TimeZone::tzif(name, tzif) {
return tz;
}
Expand Down Expand Up @@ -116,7 +116,6 @@
utc: bool,
format: Format,
date_source: DateSource,
set_to: Option<Zoned>,
debug: bool,
}

Expand Down Expand Up @@ -424,30 +423,26 @@
}
};

let set_to = match matches.get_one::<String>(OPT_SET) {
None => None,
Some(input) => match parse_date(input, &now, DebugOptions::new(debug_mode, true), false) {
Ok(ParsedDateTime::InRange(date)) => Some(date),
if let Some(input) = matches.get_one::<String>(OPT_SET) {
match parse_date(input, &now, DebugOptions::new(debug_mode, true), false) {
Ok(ParsedDateTime::InRange(date)) => {
return set_system_datetime(convert_for_set(date, utc));
}
Ok(ParsedDateTime::Extended(_)) | Err(_) => {
return Err(Box::new(DateError::InvalidDate {
date: input.clone(),
}));
}
},
};
}
}

let settings = Settings {
utc,
format,
date_source,
set_to,
debug: debug_mode,
};

if let Some(date) = settings.set_to {
return set_system_datetime(convert_for_set(date, settings.utc));
}

let allow_extended = matches!(settings.format, Format::Default);
let output_time_zone = now.time_zone().clone();

Expand Down
Loading