1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 14:20:04 -04:00

Remove "seconds_since_midnight" from epi/eframe. Use chrono instead

chrono works both natively and on web.

Related: https://github.com/emilk/egui/issues/212
This commit is contained in:
Emil Ernerfeldt
2021-10-19 15:37:20 +02:00
parent cdd4dccf5f
commit 844dd9d7a4
17 changed files with 27 additions and 64 deletions

View File

@@ -154,3 +154,19 @@ fn test_egui_zero_window_size() {
assert!(clipped_meshes.is_empty(), "There should be nothing to show");
}
}
// ----------------------------------------------------------------------------
/// Time of day as seconds since midnight. Used for clock in demo app.
pub(crate) fn seconds_since_midnight() -> Option<f64> {
#[cfg(feature = "chrono")]
{
use chrono::Timelike;
let time = chrono::Local::now().time();
let seconds_since_midnight =
time.num_seconds_from_midnight() as f64 + 1e-9 * (time.nanosecond() as f64);
Some(seconds_since_midnight)
}
#[cfg(not(feature = "chrono"))]
None
}