MCPcopy Index your code
hub / github.com/11ty/parse-date-strings

github.com/11ty/parse-date-strings @v2.0.6

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.0.6 ↗ · + Follow
17 symbols 32 edges 4 files 5 documented · 29%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

@11ty/parse-date-strings

Features:

  • Zero dependency super minimal RFC 9557-compatible date parsing library. Date strings are also parseable by Temporal.PlainDate.from, Temporal.Instant.from, or Temporal.PlainDateTime.from to prepare for wider Temporal API support.
  • Alternatives: temporal-polyfill or js-temporal/temporal-polyfill
  • Invalid strings throw errors.
  • Time zone notes:
  • Defaults to UTC when time zone is unknown (not local time). This matches previous behavior in Eleventy and this feature maintains consistency between build and deploy servers.
  • Supports +00, +00:00, -00, or -00:00 style time zone offsets (: delimiter is optional)
  • Delimiter notes:
  • Requires a T or t or (space) delimiter with DateTime strings
  • Delimiters in dates (-) and times (:) are optional

Not supported (for RFC 9557 compatibility):

  • Standalone time formats are not supported (must be Date or DateTime)
  • ISO week date syntax is not supported (e.g. YYYY-W01-1)
  • Day of year syntax is not supported (e.g. YYYY-001, YYYY-365)
  • Fractional hours or minutes (e.g. T14.6 or T10:30.6) are not supported. Fractional seconds (e.g. milliseconds) are supported (of course).

Usage

npm install @11ty/parse-date-strings
import { parse } from "@11ty/parse-date-strings

// `parse` returns JavaScript Date

parse("2000-01-01") instanceof Date
// true

parse("2000-01-01").toUTCString()
// "Mon, 01 Jan 2001 00:00:00 GMT"

Comparisons

luxon

More strict parsing compared with Luxon’s fromISO (used in Eleventy v0.x through v3):

2016-05-25
20160525
2016-05-25T09
2016-05-25T09:24
2016-05-25T09:24:15
2016-05-25T09:24:15.123
2016-05-25T0924
2016-05-25T092415
2016-05-25T092415.123
2016-05-25T09:24:15,123

# No YYYY or YYYYMM syntax
2016                      # Dropped
2016-05                   # Dropped
201605                    # Dropped

# No ISO week date syntax
2016-W21-3                # Dropped
2016W213                  # Dropped
2016-W21-3T09:24:15.123   # Dropped
2016W213T09:24:15.123     # Dropped

# No day of year syntax (e.g. 200th day of the year)
2016-200                  # Dropped
2016200                   # Dropped
2016-200T09:24:15.123     # Dropped

# No implied current day (time-only syntax)
09:24                     # Dropped
09:24:15                  # Dropped
09:24:15.123              # Dropped
09:24:15,123              # Dropped

Core symbols most depended-on inside this repo

parse
called by 7
parse.js
shouldSkip
called by 4
test/utils.js
convertTemporalToTimestamp
called by 2
test/temporal.js
getTimezoneOffset
called by 1
parse.js
getByDateTime
called by 1
parse.js
getParts
called by 1
parse.js
parse
called by 1
parse.js
getArgs
called by 1
parse.js

Shape

Method 7
Function 6
Class 4

Languages

TypeScript100%

Modules by API surface

parse.js12 symbols
test/temporal.js4 symbols
test/utils.js1 symbols

For agents

$ claude mcp add parse-date-strings \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact