# date

> Convenience date API over Unix timestamps — now, parse, format, component extraction, and arithmetic.

# date

The `date` module is a flat convenience API for working with Unix timestamps (seconds since the epoch). All component extraction is done in UTC. Import it with `import date`.

## Functions

| Function | Signature | Description |
| --- | --- | --- |
| `now` | `date.now() → string` | current time as an RFC3339 string |
| `unix` | `date.unix() → int` | current time in Unix seconds |
| `parse` | `date.parse(s: string) → int` | parse an RFC3339 string into Unix seconds |
| `format` | `date.format(ts: int, layout: string) → string` | format a timestamp; `layout` is a Go layout or a shortcut: `"date"`, `"time"`, `"datetime"`, `"rfc3339"`, `"rfc1123"` |
| `year` | `date.year(ts: int) → int` | year of the timestamp |
| `month` | `date.month(ts: int) → int` | month, 1–12 |
| `day` | `date.day(ts: int) → int` | day of month |
| `hour` | `date.hour(ts: int) → int` | hour, 0–23 |
| `minute` | `date.minute(ts: int) → int` | minute, 0–59 |
| `second` | `date.second(ts: int) → int` | second, 0–59 |
| `weekday` | `date.weekday(ts: int) → string` | weekday name, e.g. "Monday" |
| `addDays` | `date.addDays(ts: int, n: int) → int` | timestamp `n` days later |
| `addHours` | `date.addHours(ts: int, n: int) → int` | timestamp `n` hours later |
| `addMinutes` | `date.addMinutes(ts: int, n: int) → int` | timestamp `n` minutes later |
| `diff` | `date.diff(ts1: int, ts2: int) → int` | seconds between two timestamps (`ts2 − ts1`) |
| `isLeapYear` | `date.isLeapYear(year: int) → bool` | true if the year is a leap year |

## Example

```goost
import date

let now = date.unix()
let tomorrow = date.addDays(now, 1)

print(date.format(now, "datetime"))       // 2026-05-29 14:03:21
print(date.weekday(tomorrow))             // Saturday
print(date.diff(now, tomorrow))           // 86400 seconds
```