# Eymenium standard-style time module.
# `add time` loads this file into the current scope.
# The low-level clock operations are supplied by the native interpreter.

TIME_VERSION = "1.0.0"

exp time():
    # Floating-point Unix timestamp in seconds.
    back _time_time()

exp unix():
    # Integer Unix timestamp in seconds.
    back _time_unix()

exp millis():
    # Integer Unix timestamp in milliseconds.
    back _time_millis()

exp sleep(seconds):
    # Pause execution for the requested number of seconds.
    _time_sleep(seconds)

exp local():
    # Local system time as YYYY-MM-DD HH:MM:SS.
    back _time_local()

exp utc():
    # UTC time as YYYY-MM-DD HH:MM:SS.
    back _time_utc()

exp components():
    # Local clock fields in a string-keyed dictionary.
    back _time_components()

exp year():
    back components()["year"]

exp month():
    back components()["month"]

exp day():
    back components()["day"]

exp hour():
    back components()["hour"]

exp minute():
    back components()["minute"]

exp second():
    back components()["second"]

exp weekday():
    # Sunday = 0, Monday = 1, ..., Saturday = 6 (C/POSIX tm convention).
    back components()["weekday"]
