iced_core/time.rs
1//! Keep track of time, both in native and web platforms!
2
3pub use web_time::Duration;
4pub use web_time::Instant;
5
6/// Creates a [`Duration`] representing the given amount of milliseconds.
7pub fn milliseconds(milliseconds: u64) -> Duration {
8 Duration::from_millis(milliseconds)
9}
10
11/// Creates a [`Duration`] representing the given amount of seconds.
12pub fn seconds(seconds: u64) -> Duration {
13 Duration::from_secs(seconds)
14}
15
16/// Creates a [`Duration`] representing the given amount of minutes.
17pub fn minutes(minutes: u64) -> Duration {
18 seconds(minutes * 60)
19}
20
21/// Creates a [`Duration`] representing the given amount of hours.
22pub fn hours(hours: u64) -> Duration {
23 minutes(hours * 60)
24}
25
26/// Creates a [`Duration`] representing the given amount of days.
27pub fn days(days: u64) -> Duration {
28 hours(days * 24)
29}