← Time Travel APIDocumentation

Documentation

Holiday-aware date mapping across years — three endpoints, one resolution engine.

01 / Overview

Conventions

Base path
/api/comparable
Methods
POST
Format
application/json
Auth
None

Endpoints

POST/api/comparable/dateMap a single date to its comparable date in a target year.
POST/api/comparable/weekMap a Sun–Sat week to the comparable week in a target year.
POST/api/comparable/rangeMap a date range (max 366 days) to the comparable range in a target year.

Resolution methods

Every response reports how the comparable date was derived:

holiday-window

The input date falls within a registered holiday’s window. The comparable date preserves the same offset from that holiday’s anchor in the target year.

iso-week-fallback

No holiday claims the date. The comparable date falls on the same ISO week number and day-of-week in the target year.

02 / POST /api/comparable/date

Map a single date

Maps a single calendar date to its holiday-aware comparable date in a target year.

Request body

datestring

YYYY-MM-DD — the date to map.

targetYearnumber

Calendar year to map into (1900–2100).

windowDaysnumber?

Override per-holiday window defaults (0–365).

Example

POST /api/comparable/date

{
  "date": "2024-11-28",
  "targetYear": 2026
}
200 OK

{
  "inputDate": "2024-11-28",
  "targetYear": 2026,
  "comparableDate": "2026-11-26",
  "method": "holiday-window",
  "holiday": {
    "id": "thanksgiving",
    "name": "Thanksgiving",
    "anchorDate": "2024-11-28",
    "offset": 0,
    "targetAnchorDate": "2026-11-26"
  }
}

03 / POST /api/comparable/week

Map a business week

Maps a Sun–Sat business week to its comparable week in a target year. Provide any date within the desired week; the engine snaps to the Sunday that opens the week, resolves it (holiday-window or ISO-week fallback), then extends the result +6 days.

Request body

weekOfstring

YYYY-MM-DD — any date within the week of interest.

targetYearnumber

Calendar year to map into (1900–2100).

windowDaysnumber?

Override per-holiday window defaults (0–365).

Example

POST /api/comparable/week

{
  "weekOf": "2024-11-27",
  "targetYear": 2026
}
200 OK

{
  "inputWeek": {
    "startDate": "2024-11-24",
    "endDate": "2024-11-30"
  },
  "targetYear": 2026,
  "comparableWeek": {
    "startDate": "2026-11-22",
    "endDate": "2026-11-28"
  },
  "method": "iso-week-fallback",
  "isoWeek": {
    "isoWeekYear": 2024,
    "week": 48,
    "dayOfWeek": 7
  }
}

04 / POST /api/comparable/range

Map a date range

Maps a date range to its comparable range in a target year, day by day. Maximum range: 366 days. A per-day breakdown is included automatically for ranges ≤ 14 days; set includeDays: true to force it for longer ranges.

Request body

startDatestring

YYYY-MM-DD.

endDatestring

YYYY-MM-DD — must be on or after startDate.

targetYearnumber

Calendar year to map into (1900–2100).

windowDaysnumber?

Override per-holiday window defaults (0–365).

includeDaysboolean?

Force the per-day breakdown in the response. Defaults to auto based on range length.

Example

POST /api/comparable/range

{
  "startDate": "2024-11-27",
  "endDate": "2024-11-29",
  "targetYear": 2026
}
200 OK

{
  "inputRange": {
    "startDate": "2024-11-27",
    "endDate": "2024-11-29"
  },
  "targetYear": 2026,
  "comparableRange": {
    "startDate": "2026-11-26",
    "endDate": "2026-11-28"
  },
  "days": [
    { "inputDate": "2024-11-27", "...": "..." },
    { "inputDate": "2024-11-28", "...": "..." },
    { "inputDate": "2024-11-29", "...": "..." }
  ]
}

Each entry in days has the same shape as a /date response.

05 / Errors

Errors & validation

Every endpoint returns 400 with the same error shape when a request fails validation:

400 Bad Request

{
  "error": "string describing what's wrong"
}

Validation rules

bodyrequired

Must be valid JSON and a JSON object.

date fieldsrequired

date / weekOf / startDate / endDate must be strings in YYYY-MM-DD format.

targetYearrequired

Must be an integer between 1900 and 2100.

windowDaysoptional

When present, must be an integer between 0 and 365.

endDaterange only

Must be on or after startDate; the range must not exceed 366 days.

06 / Holiday registry

Holiday registry

The 21 US holidays checked against every input date. The closest holiday whose window — the request’s windowDays override, or else that holiday’s own default window — contains the date wins. Otherwise the response falls back to matching the same ISO week number and day-of-week.

NameWindowFederalType
New Year's Day±3Yesfixed
MLK Day±2Yesfloating
Valentine's Day±2fixed
Presidents' Day±2Yesfloating
St. Patrick's Day±2fixed
Easter±10floating
Tax Day±2fixed
Mother's Day±2floating
Memorial Day±4Yesfloating
Father's Day±2floating
Juneteenth±2Yesfixed
Independence Day±3Yesfixed
Labor Day±4Yesfloating
Columbus Day±2Yesfloating
Halloween±2fixed
Veterans Day±2Yesfixed
Thanksgiving±5Yesfloating
Black Friday±2floating
Christmas Eve±2fixed
Christmas±4Yesfixed
New Year's Eve±2fixed
← Back home