method Date.parse
Parses ISO 8601 (.Iso8601, the default) or a pattern: Date.parse(s, "dd.MM.yyyy").
Example:
use std.time { Date }
fn main() io {
print("{Date.parse("03.11.2026", "dd.MM.yyyy")!.toIso()}")
match Date.parse("2026-13-40") {
Date d => print(d.toIso())
ParseError _ => print("invalid")
}
}Output
2026-11-03 invalid
pub(api) static fn parse(text: str, format: TimeFormat | str = .Iso8601) -> Date | ParseErrorSince. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
text | str |
format | TimeFormat | str = .Iso8601 |
Returns
Errors
ParseError@error- `ParseError` when the text does not match the format.
Effects
none declared (pure unless the body says otherwise)
Defined in: std/time/time.oxl:1573