Skip to content

Instantly share code, notes, and snippets.

@matthewjberger
Created September 5, 2023 16:13
Show Gist options
  • Save matthewjberger/f4de54df00cd0a183fd1fbad380016f1 to your computer and use it in GitHub Desktop.
Save matthewjberger/f4de54df00cd0a183fd1fbad380016f1 to your computer and use it in GitHub Desktop.
/// Time of day as seconds since midnight. Used for clock in demo app.
pub(crate) fn seconds_since_midnight() -> f64 {
use chrono::Timelike;
let time = chrono::Local::now().time();
time.num_seconds_from_midnight() as f64 + 1e-9 * (time.nanosecond() as f64)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment