Skip to content

Commit 4b4b779

Browse files
authored
Merge pull request #577 from Integral-Tech/sign-detect-plus
refactor: replace manual sign detection with format spec "+"
2 parents dfeabbb + ef8c28e commit 4b4b779

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

src/main.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,7 @@ lazy_static! {
7979
static ref HOSTNAME: String = whoami::fallible::hostname().unwrap_or("No Hostname".to_string());
8080

8181
static ref TIMEZONE_STR: String = {
82-
let offset = chrono::Local::now().offset().local_minus_utc() / 3600;
83-
if offset.is_positive() {
84-
format!(" UTC+{} ", offset.abs())
85-
} else {
86-
format!(" UTC-{} ", offset.abs())
87-
}
82+
format!(" UTC{:+} ", chrono::Local::now().offset().local_minus_utc() / 3600)
8883
};
8984
}
9085

src/types/command/impl_completion.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ impl CommandCompletion for Command {
4545
"insensitive",
4646
"sensitive",
4747
]),
48-
CMD_SET_DISPLAY_MODE => CompletionKind::Custom(vec![
49-
"default", "minimal", "hsplit",
50-
]),
48+
CMD_SET_DISPLAY_MODE => CompletionKind::Custom(vec!["default", "minimal", "hsplit"]),
5149
CMD_SET_LINEMODE => CompletionKind::Custom(vec![
5250
"all", "group", "mtime", "none", "perm", "size", "user",
5351
]),

src/types/command/impl_from_str.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,9 +558,9 @@ impl std::str::FromStr for Command {
558558
"minimal" => Ok(Self::SetDisplayMode(DisplayMode::Minimal)),
559559
"hsplit" => Ok(Self::SetDisplayMode(DisplayMode::HSplit)),
560560
_ => Err(AppError::new(
561-
AppErrorKind::InvalidParameters,
562-
format!("{}: Unknown option '{}'", command, arg),
563-
))
561+
AppErrorKind::InvalidParameters,
562+
format!("{}: Unknown option '{}'", command, arg),
563+
)),
564564
}
565565
} else if command == CMD_SET_LINEMODE {
566566
Ok(Self::SetLineMode(LineMode::from_string(arg)?))

0 commit comments

Comments
 (0)