An open API service indexing awesome lists of open source software.

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

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"]()]
```