Tea
DocsPlaygroundExamplesReferenceCommunity
GitHub

Tea Language

A strongly typed scripting language for native tools.

© 2026 Tea Language.

ContributingCommunityRepository

Language Runtime

Built-ins

Standard Library

std.argsstd.assertstd.audiostd.envstd.fsstd.httpstd.netstd.jsonstd.parsestd.pathstd.processstd.regexstd.stringstd.timestd.url

Standard Library

std.time

Time helpers for tool-style scripts.

Exported functions

pub def now() -> Timestamp

Return the current UTC timestamp.

pub def now_unix_seconds() -> Int

Return the current Unix timestamp in seconds.

pub def now_unix_millis() -> Int

Return the current Unix timestamp in milliseconds.

pub def sleep(delay_ms: Int) -> Void

Pause the current thread for the specified number of milliseconds.

pub def sleep_for(duration: Duration) -> Void

Pause the current thread for a duration value.

pub def from_unix_seconds(value: Int) -> Timestamp

Construct a timestamp from Unix seconds.

pub def from_unix_millis(value: Int) -> Timestamp

Construct a timestamp from Unix milliseconds.

pub def unix_seconds(timestamp: Timestamp) -> Int

Return the Unix seconds for a timestamp.

pub def unix_millis(timestamp: Timestamp) -> Int

Return the Unix milliseconds for a timestamp.

pub def milliseconds(value: Int) -> Duration

Create a duration in milliseconds.

pub def seconds(value: Int) -> Duration

Create a duration in seconds.

pub def minutes(value: Int) -> Duration

Create a duration in minutes.

pub def hours(value: Int) -> Duration

Create a duration in hours.

pub def days(value: Int) -> Duration

Create a duration in days.

pub def add(left: Duration, right: Duration) -> Duration

Return the sum of two durations.

pub def subtract(left: Duration, right: Duration) -> Duration

Return the difference between two durations.

pub def multiply(duration: Duration, factor: Int) -> Duration

Multiply a duration by an integer factor.

pub def between(start: Timestamp, finish: Timestamp) -> Duration

Return the elapsed duration between two timestamps.

pub def add_to(timestamp: Timestamp, duration: Duration) -> Timestamp

Add a duration to a timestamp.

pub def subtract_from(timestamp: Timestamp, duration: Duration) -> Timestamp

Subtract a duration from a timestamp.

pub def format_rfc3339(timestamp: Timestamp) -> String

Format a timestamp as an RFC3339 string in UTC.

pub def try_parse_rfc3339(text: String) -> Timestamp ! TimeError

Parse an RFC3339 string into a timestamp.

pub def parse_rfc3339(text: String) -> Timestamp

Parse an RFC3339 string and panic on invalid input.

pub def to_utc(timestamp: Timestamp) -> DateTime

Break a timestamp into UTC calendar components. Weekday is ISO numbering: 1 = Monday through 7 = Sunday.

pub def year(timestamp: Timestamp) -> Int

Return the UTC year of a timestamp.

pub def month(timestamp: Timestamp) -> Int

Return the UTC month (1-12) of a timestamp.

pub def day(timestamp: Timestamp) -> Int

Return the UTC day of month (1-31) of a timestamp.

pub def hour(timestamp: Timestamp) -> Int

Return the UTC hour (0-23) of a timestamp.

pub def minute(timestamp: Timestamp) -> Int

Return the UTC minute (0-59) of a timestamp.

pub def second(timestamp: Timestamp) -> Int

Return the UTC second (0-59) of a timestamp.

pub def weekday(timestamp: Timestamp) -> Int

Return the ISO weekday (1 = Monday .. 7 = Sunday) of a timestamp.

pub def try_format(timestamp: Timestamp, pattern: String) -> String ! TimeError

Format a timestamp with a format description such as "[year]-[month]-[day] [hour]:[minute]:[second]".

pub def format(timestamp: Timestamp, pattern: String) -> String

Format a timestamp with a format description, panicking on failure.

pub def try_parse(text: String, pattern: String) -> Timestamp ! TimeError

Parse text with a format description into a UTC timestamp. Patterns without an offset are interpreted as UTC.

pub def parse(text: String, pattern: String) -> Timestamp

Parse text with a format description, panicking on failure.

pub def try_from_calendar(in_year: Int, in_month: Int, in_day: Int, in_hour: Int, in_minute: Int, in_second: Int) -> Timestamp ! TimeError

Build a UTC timestamp from calendar components.

pub def from_calendar(in_year: Int, in_month: Int, in_day: Int, in_hour: Int, in_minute: Int, in_second: Int) -> Timestamp

Build a UTC timestamp from calendar components, panicking on failure.

pub def format_date(timestamp: Timestamp) -> String

Format a timestamp as "YYYY-MM-DD" in UTC.

pub def format_time(timestamp: Timestamp) -> String

Format a timestamp as "HH:MM:SS" in UTC.