@ende/chronver
ende add jsr:@ende/chronverVersion 2026.10.17 on JSR.
The Chronological Version parser.
Adapted from ChronVer. See https://chronver.org for the spec.
import { format, greaterThan, increment, parse } from "@ende/chronver";
import { assert, assertEquals } from "@ende/assert";
const version = parse("2024.04.03.1");
assertEquals(version, {
year: 2024,
month: 4,
day: 3,
changeset: 1,
isBreaking: false
});
assertEquals(format(version), "2024.04.03.1");
assert(greaterThan(parse("2024.04.04"), version));
// Same day: bump the changeset. Another day: that date's version.
assertEquals(format(increment(version, new Date(2024, 3, 3))), "2024.04.03.2");
assertEquals(format(increment(version, new Date(2024, 3, 4))), "2024.04.04");
Format
YYYY.MM.DD[.CHANGESET][-FEATURE|-break]
| Version | Description |
|---|---|
2025.07.21 |
Released July 21st, 2025 |
2025.07.21.1 |
First hotfix that day |
2025.07.21.3 |
Third change that day |
2025.07.21-feature |
Feature branch for that date |
2025.07.21.1-feature |
Feature branch with changeset |
2025.07.21.1-break |
Breaking change |
The date must be a real calendar date: 2024.02.29 is valid, 2023.02.29
and 2024.04.31 are not. Dates are read and written in local time.
Modules
@ende/chronver/can-parse@ende/chronver/compare@ende/chronver/equals@ende/chronver/format@ende/chronver/from-date@ende/chronver/greater-or-equal@ende/chronver/greater-than@ende/chronver/increment@ende/chronver/is-chronver@ende/chronver/less-or-equal@ende/chronver/less-than@ende/chronver/parse@ende/chronver/sort@ende/chronver/try-parse@ende/chronver/types
Exports
canParse— Returns true if the string can be parsed as ChronVer.ChronVer— A ChronVer object parsed into its constituent parts.compare— Compare two ChronVers.equals— Returns `true` if both ChronVers are equivalent.format— Formats a ChronVer object into a string.fromDate— Creates a ChronVer from a date, using the date's local time.greaterOrEqual— Greater than or equal to comparison for two ChronVers.greaterThan— Greater than comparison for two ChronVers.increment— Returns the next version on the given date, in local time.isChronVer— Checks to see if value is a valid ChronVer object: one that format accepts and that parse reads back unchanged. The year must be from 1 to 9999, the date a real calendar date and the changeset a non-negative safe integer. The feature, if present, may only contain letters, digits and hyphens (not only hyphens), can't be `break`, and can't be combined with `isBreaking`.lessOrEqual— Less than or equal to comparison for two ChronVers.lessThan— Less than comparison for two ChronVers.parse— Parses a string as a ChronVer, returning a ChronVer object.sort— Sorts ChronVer strings, returning a new array.tryParse— Returns the parsed ChronVer, or `undefined` if it's not valid.