SultanC
  1. Home
  2. Examples
  3. Time

Formatting and parsing ISO 8601 dates

time/iso_dates.sn
// Formatting and parsing ISO 8601 dates.
import std.io.println;
import std.text.number;
import std.time.calendar;
import std.time.date;

def main(): int {
    match new_calendar_date(2026, 11, 4) with
    | option.none -> { return 1; }
    | option.some(date) -> {
        match format_iso_date(&date) with
        | option.some(text) -> { println(text); }
        | option.none -> { };
    };
    return 0;
}

Run it

With the interpreter, without compiling:

./build/sultanc run examples/en/time/iso_dates.sn

Or compile it to an executable:

./build/sultanc examples/en/time/iso_dates.sn -o build/example && ./build/example

Source on GitHub   All examples