Every operator a .lolo program can call, from the canonical registry the compiler bakes.
Namespaces on this page: format/, time/.
format/bytesFormat bytes as human-readable size
(format/bytes n)Parameters
| Name | Type | Description |
|---|---|---|
n | number | Bytes |
Returns: string
Example
(format/bytes 2500000) // => "2.4 MB"format/creditCardFormat credit card with masked digits
(format/creditCard str)Parameters
| Name | Type | Description |
|---|---|---|
str | string | Card number |
Returns: string
Example
(format/creditCard "4111111111111234") // => "•••• •••• •••• 1234"format/currencyFormat as currency
(format/currency n currency locale)Parameters
| Name | Type | Description |
|---|---|---|
n | number | Amount |
currency | string | Currency code (USD, EUR, etc.) |
locale | string | Locale |
Returns: string
Example
(format/currency 1234.56 "USD") // => "$1,234.56"format/listFormat array as natural language list
(format/list arr style)Parameters
| Name | Type | Description |
|---|---|---|
arr | array | Array of strings |
style | string | "and" or "or" |
Returns: string
Example
(format/list (Alice "Bob" "Charlie") "and") // => "Alice, Bob, and Charlie"format/numberFormat number with locale-aware separators
(format/number n opts)Parameters
| Name | Type | Description |
|---|---|---|
n | number | Number to format |
opts | object | Format options (decimals, locale) |
Returns: string
Example
(format/number 1234567.89) // => "1,234,567.89"format/ordinalFormat number as ordinal (1st, 2nd, 3rd)
(format/ordinal n)Parameters
| Name | Type | Description |
|---|---|---|
n | number | Number |
Returns: string
Example
(format/ordinal 42) // => "42nd"format/percentFormat as percentage
(format/percent n decimals)Parameters
| Name | Type | Description |
|---|---|---|
n | number | Number (0.5 = 50%) |
decimals | number | Decimal places |
Returns: string
Example
(format/percent 0.856 1) // => "85.6%"format/phoneFormat phone number
(format/phone str format)Parameters
| Name | Type | Description |
|---|---|---|
str | string | Phone number digits |
format | string | Format pattern |
Returns: string
Example
(format/phone "5551234567") // => "(555) 123-4567"format/pluralFormat count with singular/plural word
(format/plural n singular plural)Parameters
| Name | Type | Description |
|---|---|---|
n | number | Count |
singular | string | Singular form |
plural | string | Plural form |
Returns: string
Example
(format/plural 5 "item" "items") // => "5 items"time/addAdd time to timestamp
(time/add date amount unit)Parameters
| Name | Type | Description |
|---|---|---|
date | number | Timestamp |
amount | number | Amount to add |
unit | string | Time unit (year/month/week/day/hour/minute/second/ms) |
Returns: number
Example
(time/add (time/now) 7 "day")time/dayGet day of month from timestamp (1-31)
(time/day date)Parameters
| Name | Type | Description |
|---|---|---|
date | number | Timestamp |
Returns: number
Example
(time/day 1700000000000) // => 14time/diffDifference between timestamps
(time/diff a b unit)Parameters
| Name | Type | Description |
|---|---|---|
a | number | First timestamp |
b | number | Second timestamp |
unit | string | Result unit |
Returns: number
Example
(time/diff 1700000000000 ["time/now"] "year")time/durationFormat milliseconds as duration ("2h 30m")
(time/duration ms)Parameters
| Name | Type | Description |
|---|---|---|
ms | number | Duration in milliseconds |
Returns: string
Example
(time/duration 9000000) // => "2h 30m"time/endOfGet end of time period
(time/endOf date unit)Parameters
| Name | Type | Description |
|---|---|---|
date | number | Timestamp |
unit | string | Time unit |
Returns: number
Example
(time/endOf (time/now) "month")time/formatFormat timestamp to string
(time/format date format)Parameters
| Name | Type | Description |
|---|---|---|
date | number | Timestamp |
format | string | Format pattern |
Returns: string
Example
(time/format 1700000000000 "MMM DD, YYYY")time/hourGet hour from timestamp (0-23)
(time/hour date)Parameters
| Name | Type | Description |
|---|---|---|
date | number | Timestamp |
Returns: number
Example
(time/hour 1700000000000)time/isAfterCheck if a is after b
(time/isAfter a b)Parameters
| Name | Type | Description |
|---|---|---|
a | number | First timestamp |
b | number | Second timestamp |
Returns: boolean
Example
(time/isAfter ["time/now"] 1700000000000)time/isBeforeCheck if a is before b
(time/isBefore a b)Parameters
| Name | Type | Description |
|---|---|---|
a | number | First timestamp |
b | number | Second timestamp |
Returns: boolean
Example
(time/isBefore 1700000000000 1700086400000)time/isBetweenCheck if date is between start and end
(time/isBetween date start end)Parameters
| Name | Type | Description |
|---|---|---|
date | number | Timestamp to check |
start | number | Range start |
end | number | Range end |
Returns: boolean
Example
(time/isBetween ["time/now"] 1700000000000 2000000000000)time/isFutureCheck if timestamp is in the future
(time/isFuture date)Parameters
| Name | Type | Description |
|---|---|---|
date | number | Timestamp |
Returns: boolean
Example
(time/isFuture 2000000000000)time/isPastCheck if timestamp is in the past
(time/isPast date)Parameters
| Name | Type | Description |
|---|---|---|
date | number | Timestamp |
Returns: boolean
Example
(time/isPast 1700000000000)time/isSameCheck if timestamps are same (optionally by unit)
(time/isSame a b unit)Parameters
| Name | Type | Description |
|---|---|---|
a | number | First timestamp |
b | number | Second timestamp |
unit | string | Comparison unit |
Returns: boolean
Example
(time/isSame 1700000000000 1700001000000 "day")time/isTodayCheck if timestamp is today
(time/isToday date)Parameters
| Name | Type | Description |
|---|---|---|
date | number | Timestamp |
Returns: boolean
Example
(time/isToday ["time/now"])time/minuteGet minute from timestamp (0-59)
(time/minute date)Parameters
| Name | Type | Description |
|---|---|---|
date | number | Timestamp |
Returns: number
Example
(time/minute 1700000000000)time/monthGet month from timestamp (1-12)
(time/month date)Parameters
| Name | Type | Description |
|---|---|---|
date | number | Timestamp |
Returns: number
Example
(time/month 1700000000000) // => 11time/nowCurrent timestamp
(time/now)Returns: number
Example
(time/now) // => 1705593600000time/parseParse string to timestamp
(time/parse str format)Parameters
| Name | Type | Description |
|---|---|---|
str | string | Date string |
format | string | Format pattern |
Returns: number
Example
(time/parse "2024-01-18" "YYYY-MM-DD")time/relativeFormat as relative time ("2 hours ago", "in 3 days")
(time/relative date)Parameters
| Name | Type | Description |
|---|---|---|
date | number | Timestamp |
Returns: string
Example
(time/relative 1700000000000) // => "2 hours ago"time/secondGet second from timestamp (0-59)
(time/second date)Parameters
| Name | Type | Description |
|---|---|---|
date | number | Timestamp |
Returns: number
Example
(time/second 1700000000000)time/startOfGet start of time period
(time/startOf date unit)Parameters
| Name | Type | Description |
|---|---|---|
date | number | Timestamp |
unit | string | Time unit (year/month/week/day/hour/minute) |
Returns: number
Example
(time/startOf (time/now) "month")time/subtractSubtract time from timestamp
(time/subtract date amount unit)Parameters
| Name | Type | Description |
|---|---|---|
date | number | Timestamp |
amount | number | Amount to subtract |
unit | string | Time unit |
Returns: number
Example
(time/subtract (time/now) 1 "hour")time/todayToday at midnight (local time)
(time/today)Returns: number
Example
(time/today)time/weekdayGet day of week (0=Sunday, 6=Saturday)
(time/weekday date)Parameters
| Name | Type | Description |
|---|---|---|
date | number | Timestamp |
Returns: number
Example
(time/weekday 1700000000000) // => 2 (Tuesday)time/yearGet year from timestamp
(time/year date)Parameters
| Name | Type | Description |
|---|---|---|
date | number | Timestamp |
Returns: number
Example
(time/year 1700000000000) // => 2023The language where the rule is the program.