summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLibravatar Héctor <hector@hecrj.dev>2025-01-24 18:59:44 +0100
committerLibravatar GitHub <noreply@github.com>2025-01-24 18:59:44 +0100
commit5eedf5798c0fcd92cfd3f304ce9454bb6c274f09 (patch)
tree0d8d28ef8c062ea1a1651b77531ed091dfe5e561 /core
parent654c4b37148bda655f0c6676845d2b4ead801f40 (diff)
parent3d893ae01b64eb51b2f5854949c694090118e052 (diff)
downloadiced-5eedf5798c0fcd92cfd3f304ce9454bb6c274f09.tar.gz
iced-5eedf5798c0fcd92cfd3f304ce9454bb6c274f09.tar.bz2
iced-5eedf5798c0fcd92cfd3f304ce9454bb6c274f09.zip
Merge pull request #2747 from iced-rs/time-repeat-subscription
Implement `time::repeat` and simplify `Subscription::run_with`
Diffstat (limited to '')
-rw-r--r--core/src/time.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/core/src/time.rs b/core/src/time.rs
index dcfe4e41..c6e30444 100644
--- a/core/src/time.rs
+++ b/core/src/time.rs
@@ -2,3 +2,28 @@
pub use web_time::Duration;
pub use web_time::Instant;
+
+/// Creates a [`Duration`] representing the given amount of milliseconds.
+pub fn milliseconds(milliseconds: u64) -> Duration {
+ Duration::from_millis(milliseconds)
+}
+
+/// Creates a [`Duration`] representing the given amount of seconds.
+pub fn seconds(seconds: u64) -> Duration {
+ Duration::from_secs(seconds)
+}
+
+/// Creates a [`Duration`] representing the given amount of minutes.
+pub fn minutes(minutes: u64) -> Duration {
+ seconds(minutes * 60)
+}
+
+/// Creates a [`Duration`] representing the given amount of hours.
+pub fn hours(hours: u64) -> Duration {
+ minutes(hours * 60)
+}
+
+/// Creates a [`Duration`] representing the given amount of days.
+pub fn days(days: u64) -> Duration {
+ hours(days * 24)
+}