Skip to content

uwe-schwarz/rfc3339-date

v0.1.0MIT

RFC3339 Instant tools wrapping https://rfc3339.date (now, validate, convert, parse, tz_convert). Canonical hub: Instant = { rfc3339z, unix, unixms }. Fun project — not a reliable time source.

rfc3339.date

Cloudflare Worker API for RFC3339 validation, encoding conversion, human-friendly timezone conversion, timezone offsets/transitions, and leap second dataset access.

Run

pnpm install
pnpm dev

Quality Checks

pnpm run checks

pnpm run checks runs all quality gates in sequence: lint, typecheck, test, and build.

Deploy

pnpm deploy

Example Calls

curl https://rfc3339.date/now
curl "https://rfc3339.date/now/Europe%2FBerlin?precision=3"
curl "https://rfc3339.date/validate?value=2026-02-25T19:17:03Z&profile=rfc3339&mode=strict&json=1"
curl "https://rfc3339.date/convert?value=1700000000&in=unix&out=rfc3339"
curl "https://rfc3339.date/tz/convert?value=2026-05-22%2017:35%20CEST&to=America%2FNew_York&json=1"
curl "https://rfc3339.date/tz/convert?value=5pm%20DST&from=Europe%2FBerlin&to=America%2FNew_York&base=2026-06-01T12:00:00Z"
curl "https://rfc3339.date/tz/Europe%2FBerlin/transitions?start=2026-01-01T00:00:00Z&end=2027-01-01T00:00:00Z"
curl "https://rfc3339.date/leapseconds"

Local Event-Time Helper

For interactive local use, a shell function is more useful than a plain alias because it can accept the event time as an argument. This helper tries to discover your current IANA timezone on macOS and Linux, then calls the local worker with it. Pass an optional second argument when the source time needs an explicit from zone.

rfc3339_local_tz() {
  if [ -n "${TZ:-}" ] && [ "${TZ#*:}" = "$TZ" ]; then
    printf '%s\n' "$TZ"
    return
  fi

  if [ -L /etc/localtime ]; then
    local tz_link
    tz_link="$(readlink /etc/localtime 2>/dev/null || true)"
    case "$tz_link" in
      */zoneinfo/*)
        printf '%s\n' "${tz_link##*/zoneinfo/}"
        return
        ;;
    esac
  fi

  if command -v timedatectl >/dev/null 2>&1; then
    local tz
    tz="$(timedatectl show --property=Timezone --value 2>/dev/null)"
    if [ -n "$tz" ] && [ "$tz" != "n/a" ]; then
      printf '%s\n' "$tz"
      return
    fi
  fi

  if [ -f /etc/timezone ]; then
    local tz
    tz="$(tr -d '\n' < /etc/timezone)"
    if [ -n "$tz" ]; then
      printf '%s\n' "$tz"
      return
    fi
  fi

  printf '%s\n' "UTC"
}

rfc3339_event_local() {
  local api="${RFC3339_DATE_API:-http://127.0.0.1:8787}"
  local tz
  tz="$(rfc3339_local_tz)"

  if [ -n "${2:-}" ]; then
    curl --get "$api/tz/convert" \
      --data-urlencode "value=$1" \
      --data-urlencode "to=$tz" \
      --data-urlencode "from=$2"
    return
  fi

  curl --get "$api/tz/convert" \
    --data-urlencode "value=$1" \
    --data-urlencode "to=$tz"
}

alias eventlocal='rfc3339_event_local'

Examples:

eventlocal "tomorrow 7:30pm CET"
eventlocal "2026-05-22 17:35 CEST"
eventlocal "5pm DST" Europe/Berlin

If the input needs a specific source region for DST/STD disambiguation, call curl directly and add from=... plus an optional base=....

curl --get "http://127.0.0.1:8787/tz/convert" \
  --data-urlencode "value=5pm DST" \
  --data-urlencode "from=Europe/Berlin" \
  --data-urlencode "to=$(rfc3339_local_tz)" \
  --data-urlencode "base=2026-06-01T12:00:00Z"