Sugar uses the namespace access operator :: to group related functions. Date properties use ordinary . access.
Create dates
let now: Date = Date::now();
let release: Date = Date::from(2026, 9, 7);
Date::now() returns the current date and time. Date::from(year, month, day) creates midnight on a calendar date and rejects invalid dates.
Dates use the active timezone. Automations use their configured timezone when present. Otherwise JOI uses the detected user timezone when available, then Pacific Time as a fallback.
Date variables may use the explicit : Date type. Date inputs are not supported, so a Date variable cannot use input: true.
Date properties
now.year
now.month
now.day
now.weekday
now.hour
now.minute
now.timestamp
weekday is a lowercase name such as "monday". timestamp is Unix time in milliseconds.
A date written directly as output appears as YYYY-MM-DD when created with Date::from(), or YYYY-MM-DD HH:mm when it includes a time.
Durations
Duration::minutes(30)
Duration::hours(24)
Duration::days(7)
Duration::weeks(2)
Durations represent fixed elapsed time. Sugar intentionally has no month or year duration because their lengths vary.
Add or subtract a Duration from a Date:
let tomorrow: Date = Date::now() + Duration::days(1);
let nextWeek: Date = Date::now() + Duration::weeks(1);
let earlier: Date = Date::now() - Duration::hours(3);
Dates support ==, !=, <, <=, >, and >=. Duration values can also be added to or subtracted from other Duration values.