Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Formatting Negative Times #580

Merged
merged 1 commit into from
Oct 9, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/timing/formatter/complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Display for Inner {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
if let Some(time) = self.0 {
let (total_seconds, nanoseconds) = time.to_seconds_and_subsec_nanoseconds();
let (total_seconds, nanoseconds) = if total_seconds < 0 {
let (total_seconds, nanoseconds) = if (total_seconds | nanoseconds as i64) < 0 {
// Since, this Formatter is used for writing out split files, we
// have to use an ASCII Minus here.
f.write_str(ASCII_MINUS)?;
Expand Down
4 changes: 2 additions & 2 deletions src/timing/formatter/days.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ impl TimeFormatter<'_> for Days {
impl Display for Inner {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
if let Some(time) = self.time {
let total_seconds = time.to_duration().whole_seconds();
let total_seconds = if total_seconds < 0 {
let (total_seconds, nanoseconds) = time.to_seconds_and_subsec_nanoseconds();
let total_seconds = if (total_seconds | nanoseconds as i64) < 0 {
f.write_str(MINUS)?;
(-total_seconds) as u64
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/timing/formatter/delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl Display for Inner {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
if let Some(time) = self.time {
let (total_seconds, nanoseconds) = time.to_seconds_and_subsec_nanoseconds();
let (total_seconds, nanoseconds) = if total_seconds < 0 {
let (total_seconds, nanoseconds) = if (total_seconds | nanoseconds as i64) < 0 {
f.write_str(MINUS)?;
((-total_seconds) as u64, (-nanoseconds) as u32)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/timing/formatter/regular.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl Display for Inner {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
if let Some(time) = self.time {
let (total_seconds, nanoseconds) = time.to_seconds_and_subsec_nanoseconds();
let (total_seconds, nanoseconds) = if total_seconds < 0 {
let (total_seconds, nanoseconds) = if (total_seconds | nanoseconds as i64) < 0 {
f.write_str(MINUS)?;
((-total_seconds) as u64, (-nanoseconds) as u32)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/timing/formatter/segment_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl Display for Inner {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
if let Some(time) = self.time {
let (total_seconds, nanoseconds) = time.to_seconds_and_subsec_nanoseconds();
let (total_seconds, nanoseconds) = if total_seconds < 0 {
let (total_seconds, nanoseconds) = if (total_seconds | nanoseconds as i64) < 0 {
f.write_str(MINUS)?;
((-total_seconds) as u64, (-nanoseconds) as u32)
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/timing/formatter/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ impl TimeFormatter<'_> for Time {
impl Display for TimeInner {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
if let Some(time) = self.time {
let total_seconds = time.to_duration().whole_seconds();
let total_seconds = if total_seconds < 0 {
let (total_seconds, nanoseconds) = time.to_seconds_and_subsec_nanoseconds();
let total_seconds = if (total_seconds | nanoseconds as i64) < 0 {
f.write_str(MINUS)?;
(-total_seconds) as u64
} else {
Expand Down