Przejdź do treści
Biblioteka skilli
Medycyna i zdrowie · Konwersja i formaty

cosyte-dates

/cosyte-dates

Waliduje i konwertuje części dat zwracane przez parsery @cosyte do ISO 8601, bez wymyślania precyzji ani strefy czasowej.

Repozytorium
agent-skills ↗
Licencja
MIT
Ostatnia zmiana repozytorium
12.11.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
4
Przestarzałość

Brak sygnałów. Repozytorium zmienione 12.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Waliduje i konwertuje części dat zwracane przez parsery @cosyte do ISO 8601, bez wymyślania precyzji ani strefy czasowej.

Oryginalny opis (EN)

Validates and converts the date parts that the @cosyte parsers return, with @cosyte/dates, without inventing precision or a timezone. Use when the user needs to turn an HL7 v2, X12, FHIR, C-CDA, NCPDP, ASTM or DICOM date or timestamp from a @cosyte parser into an ISO 8601 string, a Temporal value or an absolute instant; to validate a year, month, day, hour, minute, second, fraction and offsetMinutes object; to find a value's precision (a year-only date of birth stays a year); or to place a local time with no offset into a stated IANA zone. Not for parsing free-form or vendor date text, two-dig

Jak działa

  1. When to use it
  2. Install
  3. Minimal example
  4. Key API
  5. Limits and known defects
  6. PHI handling
  7. Docs
Sekcje z nagłówków SKILL.md, w oryginale · 140 linii, 922 słów
Podgląd SKILL.md
---
name: cosyte-dates
description: "Validates and converts the date parts that the @cosyte parsers return, with @cosyte/dates, without inventing precision or a timezone. Use when the user needs to turn an HL7 v2, X12, FHIR, C-CDA, NCPDP, ASTM or DICOM date or timestamp from a @cosyte parser into an ISO 8601 string, a Temporal value or an absolute instant; to validate a year, month, day, hour, minute, second, fraction and offsetMinutes object; to find a value's precision (a year-only date of birth stays a year); or to place a local time with no offset into a stated IANA zone. Not for parsing free-form or vendor date text, two-digit years, date arithmetic or locale formatting. To parse the message itself use the parser skill for its format, such as cosyte-hl7 or cosyte-x12."
license: MIT
metadata:
  package: "@cosyte/dates"
  version: "0.1.6"
  docs: "https://docs.cosyte.com/dates/intro"
---

# @cosyte/dates

Date and time utilities for the `@cosyte/*` healthcare parsers: precision-preserving conversion and
validation that never guesses a timezone. The parsers hand back spec-native date parts rather than
JavaScript `Date` objects; this package validates and converts those parts.

## When to use it

- "Convert this HL7 timestamp to ISO 8601 without losing precision."
- "Turn the parsed date of birth into a `Temporal.PlainDate`."
- "Is this date valid?", "February 29 in a non-leap year", "which component is wrong?"
- "Get an absolute instant from a timestamp that has no offset, in `America/New_York`."
- "What precision does this value have: year, day, minute?"

Use another skill when:

- You need to parse the message that carries the date: use the format's skill (cosyte-hl7,
  cosyte-x12, cosyte-fhir, cosyte-ccda, cosyte-ncpdp, cosyte-astm, cosyte-dicom). Several parsers
  also export their own `toObject`, `toISO` and `toDate` for their date types; the format skill
  covers those.

## Install

```bash
npm install @cosyte/dates
```

The README leads with `pnpm add @cosyte/dates`. Node 22.0.0 or later. ESM only: there is no
CommonJS build, so `require()` will not load it. One runtime dependency, `temporal-polyfill`;
`Temporal` is re-exported from this package, so use that export rather than installing a second copy.

## Minimal example

Adapted from the README usage block (no real data; the dates are invented).

```ts
import {
  MissingZoneError,
  precisionOf,
  toISO,
  toInstant,
  toTemporal,
  validateParts,
} from "@cosyte/dates";

// A date that arrived as a year and nothing more. It stays a year. These dates are invented
// event dates; a date of birth or of service belongs to a person, so print its precision, not the
// date.
const reportYear = { year: 2024 };
console.log(toISO(reportYear), "| precision:", precisionOf(reportYear));

// A calendar date. No midnight is invented and no zone is attached.
const reportDate = { year: 2024, month: 5, day: 7 };
console.log(toISO(reportDate), "| Temporal:", toTemporal(reportDate).constructor.name);

// A timestamp whose sender stated its offset. The offset is kept exactly.
const collected = { year: 2024, month: 5, day: 7, hour: 13, minute: 45, offsetMinutes: 330 };
console.log(toISO(collected), "->", toInstant(collected).toString());

// The same timestamp with no offset. Nothing guesses one.
const unknownZone = { year: 2024, month: 5, day: 7, hour: 13, minute: 45 };
try {
  toInstant(unknownZone);
} catch (error) {
  if (error instanceof MissingZoneError) console.log(error.name);
}

// Supplying the zone is the caller's decision.
console.log(toInstant(unknownZone, { timeZone: "America/New_York" }).toString());

// A date that does not exist is refused, and says which rule it broke.
const result = validateParts({ year: 2025, month: 2, day: 29 });
console.log(result.valid ? "valid" : result.issues[0]?.message);
```

The README shows lines like these for the year, date, offset, missing-zone and invalid-date cases,
identical under every host `TZ`. The dates here are invented event dates, not the README's, and the
zoned line in this snippet is our addition and is not in the README output:

```text
2024 | precision: year
2024-05-07 | Temporal: PlainDate
2024-05-07T13:45+05:30 -> 2024-05-07T08:15:00Z
MissingZoneError
day 29 does not exist: February 2025 has 28 days, because 2025 is not a leap year in the proleptic Gregorian calendar
```

## Key API

- `validateParts(value)`: checks a value against the parts contract. Never throws; returns every
  fault (`{ valid, issues }`).
- `isValidParts(value)`: the same check as a type guard. `assertValidParts(value)`: returns the
  parts or throws `DatePartsError`.
- `precisionOf(value)`: the least significant present component, `'year'` through `'fraction'`.
- `toISO(value)`: ISO 8601 at the value's own precision (`1988`, `1988-05`, `1988-05-07T13:45+05:30`).
- `toTemporal(value)`: the narrowest Temporal type that carries what the value states
  (`PlainYearMonth`, `PlainDate`, `PlainDateTime`, or `ZonedDateTime` when it has an offset).
- `toZonedDateTime(value, options?)` and `toInstant(value, options?)`: need a time of day and a
  zone. `options` is `{ timeZone?: string; offsetMinutes?: number }` and applies only when the value
  has no `offsetMinutes` of its own.
- `Temporal`: the re-exported Temporal implementation.
- Errors: `DatePartsError` (carries `issues`), `MissingZoneError`, `PrecisionError`,
  `AmbiguousLocalTimeError` (a local time that does not exist or exists twice in the named zone).

## Limits and known defects

From the README, deliberately not handled:

- No parsing of vendor date text: input is the parts object a `@cosyte/*` parser already produced.
- No two-digit years, ever, and no century window.
- No arithmetic, comparison or formatting helpers: convert with `toTemporal()` and use Temporal.
- No locale-aware output: `toISO()` renders ISO 8601 only.
- Years 1000 to 9999 only, proleptic Gregorian calendar, no leap seconds.
- `fraction` is whole nanoseconds; finer detail is refused with `finer-than-nanosecond`, not rounded.
- Zone abbreviations such as `CST` are not accepted: pass an IANA identifier or a numeric offset.
- `toTemporal()` throws for a year-only value, because Temporal has no year-only type.
- `month` is 1 to 12 (spec-native), not JavaScript's 0 to 11.
- An absent `offsetMinutes` means unknown. It does not mean UTC and it does not mean the host zone.
  Do not "fix" a `MissingZoneError` by assuming UTC; ask where the data came from.

We have no known defects on record for this package.

## PHI handling

From the README: a date of birth is PHI. The package writes nothing anywhere (no logging, telemetry,
files or network, nothing to stdout or stderr), retains nothing between calls, and refuses rather
than guesses. Its diagnostics quote one component and that component's value, never the whole date.
Whether to log an error message that may contain one component of a patient's date of birth is your
decision: prefer logging the issue code.

Use invented dates in tests and examples. Never paste real patient data into prompts, fixtures or
logs.

## Docs

- Documentation: https://docs.cosyte.com/dates/intro
- npm: https://www.npmjs.com/package/@cosyte/dates
- Source: https://github.com/cosyte/dates

Wersje

W bazie nie ma innych skilli o nazwie cosyte-dates.

Migawka bazy z 13.11.2026 · wersja paczki 9d8eb2222fb9 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100cosyte-cli
    Uruchamia polecenie cosyte z pakietu @cosyte/cli, parsując, sprawdzając i konwertując komunikaty medyczne w terminalu bez pisania kodu.
  • 100cosyte
    Kieruje zadania danych medycznych w Node.js i TypeScript do właściwego pakietu @cosyte i jego skilla, na przykład dla HL7 v2, X12, FHIR, C-CDA czy DICOM.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.