https://github.com/bgreni/chronoflare
A time interval library written in mojo
https://github.com/bgreni/chronoflare
Last synced: 6 months ago
JSON representation
A time interval library written in mojo
- Host: GitHub
- URL: https://github.com/bgreni/chronoflare
- Owner: bgreni
- License: mit
- Created: 2025-03-28T04:17:31.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-07T04:15:13.000Z (about 1 year ago)
- Last Synced: 2025-04-10T14:45:18.401Z (about 1 year ago)
- Language: Mojo
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ChronoFlare
A [`std::chrono::duration`](https://en.cppreference.com/w/cpp/chrono/duration) inspired time interval library.
## Usage
```mojo
fn sleep_seconds(wait: Seconds):
...
var s = Seconds(10)
sleep_seconds(s)
# sleep_seconds(Milliseconds(10000)) # Fails to compile
sleep_seconds(Milliseconds(10000).cast[R=Seconds.R]()) # Explicit cast to Seconds
# Arithmetic
var added = Seconds(10) + Seconds(15)
# Custom time interval
alias HalfDay = Time[Ratio[86400//2, suffix="HD"]()]
```