Skip to content

Commit

Permalink
Merge pull request #577 from Integral-Tech/sign-detect-plus
Browse files Browse the repository at this point in the history
refactor: replace manual sign detection with format spec "+"
  • Loading branch information
kamiyaa authored Nov 9, 2024
2 parents dfeabbb + ef8c28e commit 4b4b779
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
7 changes: 1 addition & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,7 @@ lazy_static! {
static ref HOSTNAME: String = whoami::fallible::hostname().unwrap_or("No Hostname".to_string());

static ref TIMEZONE_STR: String = {
let offset = chrono::Local::now().offset().local_minus_utc() / 3600;
if offset.is_positive() {
format!(" UTC+{} ", offset.abs())
} else {
format!(" UTC-{} ", offset.abs())
}
format!(" UTC{:+} ", chrono::Local::now().offset().local_minus_utc() / 3600)
};
}

Expand Down
4 changes: 1 addition & 3 deletions src/types/command/impl_completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ impl CommandCompletion for Command {
"insensitive",
"sensitive",
]),
CMD_SET_DISPLAY_MODE => CompletionKind::Custom(vec![
"default", "minimal", "hsplit",
]),
CMD_SET_DISPLAY_MODE => CompletionKind::Custom(vec!["default", "minimal", "hsplit"]),
CMD_SET_LINEMODE => CompletionKind::Custom(vec![
"all", "group", "mtime", "none", "perm", "size", "user",
]),
Expand Down
6 changes: 3 additions & 3 deletions src/types/command/impl_from_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,9 @@ impl std::str::FromStr for Command {
"minimal" => Ok(Self::SetDisplayMode(DisplayMode::Minimal)),
"hsplit" => Ok(Self::SetDisplayMode(DisplayMode::HSplit)),
_ => Err(AppError::new(
AppErrorKind::InvalidParameters,
format!("{}: Unknown option '{}'", command, arg),
))
AppErrorKind::InvalidParameters,
format!("{}: Unknown option '{}'", command, arg),
)),
}
} else if command == CMD_SET_LINEMODE {
Ok(Self::SetLineMode(LineMode::from_string(arg)?))
Expand Down

0 comments on commit 4b4b779

Please sign in to comment.