Show duration in turns
Dependencies
- [2]
GUAEZDLEAdd turns info to slow game's page - [3]
G3VK7RIBAdd FreeOrion forum's URL to slow game's - [4]
C6F7SJZIAdd players count to slow game's page - [5]
6NYILMKIAdd page for slow game
Change contents
- edit in src/pages/slow_game.rs at line 18
}fn naive_to_diff_utc(naive: chrono::NaiveDateTime,now: chrono::DateTime<chrono::Utc>,) -> (chrono::DateTime<chrono::Utc>, chrono::Duration) {let ts = chrono::DateTime::<chrono::Utc>::from_utc(naive, chrono::Utc);(ts, now - ts)}fn diff_utc_to_string((ts, diff): (chrono::DateTime<chrono::Utc>, chrono::Duration)) -> String {let (part, part_diff) = if diff.num_weeks() != 0 {("weeks", diff.num_weeks())} else if diff.num_days() != 0 {("days", diff.num_days())} else if diff.num_hours() != 0 {("hours", diff.num_hours())} else if diff.num_minutes() != 0 {("minutes", diff.num_minutes())} else {("seconds", diff.num_seconds())};format!("{} ({} {})",ts.format("%Y %b %d %H:%M UTC"),part_diff,part) - edit in src/pages/slow_game.rs at line 89
let now = chrono::Utc::now();let min_turn_ts = row.get::<_, Option<chrono::NaiveDateTime>>(4).map(|x| naive_to_diff_utc(x, now));let max_turn_ts = row.get::<_, Option<chrono::NaiveDateTime>>(5).map(|x| naive_to_diff_utc(x, now)); - replacement in src/pages/slow_game.rs at line 107
min_turn_ts: row.get::<_, Option<chrono::NaiveDateTime>>(4).map(|x| {format!("{}",chrono::DateTime::<chrono::Utc>::from_utc(x, chrono::Utc).format("%Y %b %d %H:%M UTC"))}),max_turn_ts: row.get::<_, Option<chrono::NaiveDateTime>>(5).map(|x| {format!("{}",chrono::DateTime::<chrono::Utc>::from_utc(x, chrono::Utc).format("%Y %b %d %H:%M UTC"))}),min_turn_ts: min_turn_ts.map(diff_utc_to_string),max_turn_ts: max_turn_ts.map(diff_utc_to_string),