How can I get the current date/time in Gleam? I don't see any relevant packages in the Gleam standard library.
There is no time functionality built into the standard library as of 1.0.0
.
@external
to get it via erlang.import gleam/io
pub type DateTime
// An external function that creates an instance of the type
@external(erlang, "os", "timestamp")
pub fn now() -> DateTime
pub fn main() {
io.debug(now())
}
birl
import birl
import birl/duration
pub fn main() {
let now = birl.now()
let two_weeks_later = birl.add(now, duration.weeks(2))
birl.to_iso8601(two_weeks_later)
}