Squiggly

Dates

now, time, unix, format — built on java.time.

Date/time builtins use Java’s java.time API. Available on JVM, on Scala Native via the scala-java-time shim, and on Scala.js via the same shim (squiggly’s own build pulls them in for those targets).

FunctionAritySignatureWhat
now0nowCurrent OffsetDateTime
time1time sParse an ISO-shaped string — OffsetDateTime (...Z / ...+HH:MM), Instant, or LocalDate
unix1unix vEpoch milliseconds for a date / datetime — returns a BigDecimal
format2format pattern vRender a date with a DateTimeFormatter pattern OR a named token (:date_short / :date_long / :date_full / :date_medium)

Examples

{{ format 'yyyy-MM-dd' now }}                        today

{{ d := time '2024-03-12T00:00:00Z' }}
{{ format 'MMMM d, yyyy' d }}                        March 12, 2024
{{ format ':date_long'  d }}                         March 12, 2024
{{ format ':date_full'  d }}                         Tuesday, March 12, 2024
{{ format ':date_short' d }}                         3/12/24
{{ unix d }}                                         1710201600000

{{ .page.date | format 'EEEE' }}                     day of week

Named tokens

Four shorthand patterns are recognised by format. They render identically across JVM, JS, and Native (locale is pinned to en-US so the output doesn’t drift on a runtime with a different default locale).

TokenOutput for 2024-03-12T00:00:00Z
:date_fullTuesday, March 12, 2024
:date_longMarch 12, 2024
:date_mediumMar 12, 2024
:date_short3/12/24

Pattern reference

Anything that isn’t a :-prefixed named token is passed straight to java.time.format.DateTimeFormatter.ofPattern. See the JDK reference for the full grammar. Common pieces:

PatternMeaningExample
yyyyFour-digit year2025
MMZero-padded month07
MMMShort month nameJul
MMMMFull month nameJuly
ddZero-padded day02
dDay, no padding2
EEEShort weekdayMon
EEEEFull weekdayMonday
HH24-hour hour14
mmMinutes05
ssSeconds09
ZNumeric zone+0500
zzzShort zone nameEST

A LocalDate-typed value (the shape time '2024-03-12' produces) has no time-of-day component — formatting it with HH:mm will throw. Use the full ISO form ('2024-03-12T00:00:00Z') when you need hour/minute precision.

Search

Esc
to navigate to open Esc to close