Open mohammadfawaz opened 1 year ago
as a reference, this is what solidity provides users in this regard:
I find the syntax 1 days
quite novel in programming languages.. It's certainly foreign for languages like Rust/C++. Can we do simple constants instead?
const SECOND = 1;
const MINUTE = 60;
const HOUR = 3600;
...
Constants are certainly simpler. If they were associated costs on a Time
type, we could implement conversions between them. I suppose free functions could be used to achieve the same though.
I was originally imagining something like the following:
pub struct Minutes {
seconds: u64
}
impl Minutes {
fn new(min: u64) -> Self {
Minutes {
seconds: min * 60,
}
}
}
let 5_minutes = Minutes::new(5)
If they were associated consts on a Time type
I like this - we will have this soon
Currently, the standard library provides timestamp functions that return values in TAI64 format which is hard to read. It would be nice to provide abstractions on top of that to allow retrieving common time periods such as day, hour, etc.