mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 23:43:25 +03:00
avoid some bugs if we simulate way past 24 hours
This commit is contained in:
parent
53f33a31e4
commit
0a5d945f20
@ -398,7 +398,8 @@ impl TimePanel {
|
||||
let width = 300.0;
|
||||
let y1 = 5.0;
|
||||
let height = Distance::meters(15.0);
|
||||
let percent = ui.primary.sim.time().to_percent(Time::END_OF_DAY);
|
||||
// Just clamp past 24 hours
|
||||
let percent = ui.primary.sim.time().to_percent(Time::END_OF_DAY).min(1.0);
|
||||
|
||||
// TODO rounded
|
||||
batch.push(
|
||||
|
@ -49,14 +49,14 @@ impl Time {
|
||||
|
||||
pub fn ampm_tostring(self) -> String {
|
||||
let (mut hours, minutes, seconds, remainder) = self.get_parts();
|
||||
let suffix = if hours < 12 {
|
||||
"AM"
|
||||
} else if hours < 24 {
|
||||
"PM"
|
||||
let next_day = if hours >= 24 {
|
||||
let days = hours / 24;
|
||||
hours = hours % 24;
|
||||
format!(" (+{} days)", days)
|
||||
} else {
|
||||
// Give up on the AM/PM distinction I guess. This shouldn't be used much.
|
||||
"(+1 day)"
|
||||
"".to_string()
|
||||
};
|
||||
let suffix = if hours < 12 { "AM" } else { "PM" };
|
||||
if hours == 0 {
|
||||
hours = 12;
|
||||
} else if hours >= 24 {
|
||||
@ -66,8 +66,8 @@ impl Time {
|
||||
}
|
||||
|
||||
format!(
|
||||
"{:02}:{:02}:{:02}.{:01} {}",
|
||||
hours, minutes, seconds, remainder, suffix
|
||||
"{:02}:{:02}:{:02}.{:01} {}{}",
|
||||
hours, minutes, seconds, remainder, suffix, next_day
|
||||
)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user