@tempo-kit/plugin-roman 0.0.0-stage → 2.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/math.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ import type { ClassicalRomanDate, RomanAnchor, RomanCalculationOptions, RomanDateRelation } from './types.js';
2
+ /** Returns the day of the month for the Nones (7th for March, May, July, October; 5th otherwise). */
3
+ export declare function getNonesDay(month: number): number;
4
+ /** Returns the day of the month for the Ides (15th for March, May, July, October; 13th otherwise). */
5
+ export declare function getIdesDay(month: number): number;
6
+ /** Converts an astronomical or historical year to Ab Urbe Condta (AUC). */
7
+ export declare function yearToAuc(year: number, era?: 'CE' | 'BCE'): number;
8
+ /** Converts an AUC year back to astronomical or historical representation. */
9
+ export declare function aucToYear(auc: number, format?: 'astronomical' | 'historical'): number | {
10
+ year: number;
11
+ era: 'CE' | 'BCE';
12
+ };
13
+ /** Computes the classical Roman calendar date representation for a calendar date. */
14
+ export declare function calculateClassicalRomanDate(year: number, month: number, day: number, options?: RomanCalculationOptions): ClassicalRomanDate;
15
+ /** Resolves a Roman calendar anchor back to a Gregorian date. */
16
+ export declare function calculateGregorianFromRoman(anchor: RomanAnchor, anchorMonth: number, anchorYear: number, relation: RomanDateRelation, count?: number, isBissextile?: boolean, isJulian?: boolean, bissextile?: boolean): {
17
+ year: number;
18
+ month: number;
19
+ day: number;
20
+ };
@@ -0,0 +1,19 @@
1
+ import type { ParsedRomanDate, RomanParseOptions } from './types.js';
2
+ /**
3
+ * Parses a classical Latin date expression into a Gregorian calendar date.
4
+ *
5
+ * Understands the Kalends / Nones / Ides system in any grammatical case, including:
6
+ * - Anchor dates: `Idibus Martiis`, `Id. Mart.`, `Kalendae Januariae`
7
+ * - Pridie: `Pridie Idus Octobres`, `Prid. Kal. Nov.`
8
+ * - Ante diem with numerals or Latin words: `ante diem XVII Kalendas Novembres`, `a.d. IV Id. Mart.`, `ante diem tertium decimum Kalendas Apriles`
9
+ * - The bissextile day: `a.d. bis VI Kal. Mart.`
10
+ * - A trailing or leading year: `710 AUC`, `AUC MMDCCLXXIX`, `44 BCE`, `2026`, or `options.year`
11
+ *
12
+ * The result is verified by formatting it back to its classical form, so impossible
13
+ * dates (e.g. `a.d. XX Kal. Nov.`) are rejected rather than silently mis-resolved.
14
+ *
15
+ * @param input - Latin date string
16
+ * @param options - Julian/bissextile rules and a fallback astronomical `year`
17
+ * @throws {RangeError} when the expression cannot be recognised or does not describe a real date
18
+ */
19
+ export declare function parseClassicalRomanDate(input: string, options?: RomanParseOptions): ParsedRomanDate;
@@ -0,0 +1,317 @@
1
+ import type { Tempo } from 'tempo-kit';
2
+ /**
3
+ * The three traditional lunar anchor points of the Roman month.
4
+ */
5
+ export type RomanAnchor = 'Kalends' | 'Nones' | 'Ides';
6
+ /**
7
+ * Grammatical position relative to a Roman anchor point.
8
+ * - `'on'`: Exactly on the anchor day (Ablative case, e.g. *Idibus Martiis*).
9
+ * - `'pridie'`: The day immediately before the anchor (e.g. *Pridie Idus Octobres*).
10
+ * - `'ante_diem'`: Counting inclusively backwards from the anchor (e.g. *ante diem XVII Kalendas Novembres*).
11
+ */
12
+ export type RomanDateRelation = 'on' | 'pridie' | 'ante_diem';
13
+ /**
14
+ * Grammatical case for Latin date output.
15
+ * - `'customary'`: The standard historical phrasing (Ablative on anchor, Accusative with ante diem/pridie).
16
+ * - `'nominative'`: Nominative case (e.g. *Kalendae Januariae*).
17
+ * - `'accusative'`: Accusative case (e.g. *Kalendas Januarias*).
18
+ * - `'ablative'`: Ablative case (e.g. *Kalendis Januariis*).
19
+ */
20
+ export type RomanGrammaticalCase = 'customary' | 'nominative' | 'accusative' | 'ablative';
21
+ /**
22
+ * Visual format style for classical Roman date strings.
23
+ * - `'classical'`: Full Latin words (e.g. `"ante diem XVII Kalendas Novembres"`).
24
+ * - `'short'`: Standard Latin epigraphical abbreviations (e.g. `"a.d. XVII Kal. Nov."`).
25
+ */
26
+ export type RomanFormatStyle = 'classical' | 'short';
27
+ /**
28
+ * Visual format style for consular dates.
29
+ * - `'ablative'`: Latin ablative absolute formula (e.g. `"M. Tullio Cicerone, C. Antonio Hybrida coss."`)
30
+ * - `'nominative'`: Nominative consul names (e.g. `"M. Tullius Cicero, C. Antonius Hybrida"`)
31
+ */
32
+ export type ConsularFormatStyle = 'ablative' | 'nominative';
33
+ /**
34
+ * Matched Roman consular entry for a given year.
35
+ */
36
+ export interface ConsularPair {
37
+ /** Astronomical year (0 = 1 BCE, -62 = 63 BCE). */
38
+ year: number;
39
+ /** Array of consul names for this year. */
40
+ consuls: readonly string[];
41
+ /** Classical Latin ablative dating formula. */
42
+ formatted: string;
43
+ }
44
+ /**
45
+ * Options for formatting classical Roman dates.
46
+ */
47
+ export interface RomanFormatOptions extends RomanCalculationOptions {
48
+ /**
49
+ * Grammatical case for Latin output.
50
+ *
51
+ * @default 'customary'
52
+ */
53
+ case?: RomanGrammaticalCase;
54
+ /**
55
+ * Output style: `'classical'` (full words) or `'short'` (standard abbreviations).
56
+ *
57
+ * @default 'classical'
58
+ */
59
+ style?: RomanFormatStyle;
60
+ /**
61
+ * Whether to spell out the countdown numeral as Latin words (e.g. "tertium decimum")
62
+ * instead of Roman numerals ("XIII").
63
+ *
64
+ * @default false
65
+ */
66
+ words?: boolean;
67
+ /**
68
+ * Whether to append the AUC (Ab Urbe Condita) year to the formatted output.
69
+ *
70
+ * @default false
71
+ */
72
+ auc?: boolean;
73
+ /**
74
+ * AUC formatting style: `'roman'` (e.g. "AUC MMDCCLXXIX") or `'numeric'` (e.g. "AUC 2779").
75
+ *
76
+ * @default 'roman'
77
+ */
78
+ aucFormat?: 'roman' | 'numeric';
79
+ /**
80
+ * Text casing transformation.
81
+ *
82
+ * @default 'preserve'
83
+ */
84
+ casing?: 'preserve' | 'upper' | 'lower' | 'capitalize';
85
+ /**
86
+ * Consular dating format style when rendering consuls.
87
+ *
88
+ * @default 'ablative'
89
+ */
90
+ consulStyle?: ConsularFormatStyle;
91
+ }
92
+ /**
93
+ * Options for classical Roman calendar calculations.
94
+ */
95
+ export interface RomanCalculationOptions {
96
+ /**
97
+ * Whether to use proleptic Julian calendar leap rules (every 4 years without century exceptions)
98
+ * or standard Gregorian rules.
99
+ *
100
+ * @default false (uses host environment / Gregorian rules)
101
+ */
102
+ isJulian?: boolean;
103
+ /**
104
+ * Whether to enable the classical bissextile leap day (*ante diem bis sextum Kalendas Martias*)
105
+ * on February 24 in leap years. When false, February is treated as standard 29-day countdown.
106
+ *
107
+ * @default true
108
+ */
109
+ bissextile?: boolean;
110
+ }
111
+ /**
112
+ * Options for parsing classical Latin date expressions.
113
+ */
114
+ export interface RomanParseOptions extends RomanCalculationOptions {
115
+ /**
116
+ * Astronomical year to use when the expression does not state one
117
+ * (e.g. `"Idibus Martiis"`).
118
+ */
119
+ year?: number;
120
+ }
121
+ /**
122
+ * The result of parsing a classical Latin date expression.
123
+ */
124
+ export interface ParsedRomanDate {
125
+ /** Astronomical year (0 for 1 BCE, -43 for 44 BCE). */
126
+ year: number;
127
+ /** Month of the modern calendar (1–12). */
128
+ month: number;
129
+ /** Day of the month in the modern calendar (1–31). */
130
+ day: number;
131
+ /** Year reckoned Ab Urbe Condita. */
132
+ auc: number;
133
+ /** The canonical classical representation of the resolved date. */
134
+ classical: ClassicalRomanDate;
135
+ }
136
+ /**
137
+ * A structured representation of a classical Roman calendar date.
138
+ */
139
+ export interface ClassicalRomanDate {
140
+ /**
141
+ * The applicable lunar anchor (Kalends, Nones, or Ides).
142
+ */
143
+ anchor: RomanAnchor;
144
+ /**
145
+ * The month (1–12) whose anchor is referenced.
146
+ * For dates after the Ides, this refers to the following month (e.g. October 16 references November Kalends).
147
+ */
148
+ anchorMonth: number;
149
+ /**
150
+ * The astronomical year of the referenced anchor.
151
+ * For dates in December after the Ides, this advances to the following year.
152
+ */
153
+ anchorYear: number;
154
+ /**
155
+ * Position relative to the anchor: `'on'`, `'pridie'`, or `'ante_diem'`.
156
+ */
157
+ relation: RomanDateRelation;
158
+ /**
159
+ * Inclusive countdown integer to the anchor.
160
+ * - 1 for `'on'`
161
+ * - 2 for `'pridie'`
162
+ * - 3–19 for `'ante_diem'`
163
+ */
164
+ count: number;
165
+ /**
166
+ * Roman numeral representation of the countdown integer (e.g. `'XVII'`, `'IV'`), or empty string if on the anchor.
167
+ */
168
+ romanNumeral: string;
169
+ /**
170
+ * Whether this date is the intercalated bissextile leap day (*ante diem bis sextum Kalendas Martias*, Feb 24 in leap years).
171
+ */
172
+ isBissextile: boolean;
173
+ /**
174
+ * Day of the month in the modern calendar (1–31).
175
+ */
176
+ day: number;
177
+ /**
178
+ * Month of the modern calendar (1–12).
179
+ */
180
+ month: number;
181
+ /**
182
+ * Astronomical year (e.g. 2026, 0 for 1 BCE, -43 for 44 BCE).
183
+ */
184
+ year: number;
185
+ /**
186
+ * Year reckoned Ab Urbe Condita (AUC, founded 753 BCE).
187
+ */
188
+ auc: number;
189
+ /**
190
+ * Full Latin phrasing (e.g. `"ante diem XVII Kalendas Novembres"`, `"Idibus Martiis"`).
191
+ */
192
+ latin: string;
193
+ /**
194
+ * Standard Latin abbreviation (e.g. `"a.d. XVII Kal. Nov."`, `"Id. Mart."`).
195
+ */
196
+ shortLatin: string;
197
+ /**
198
+ * Full Latin phrasing in the Nominative case (e.g. `"Kalendae Januariae"`, `"Idus Martiae"`).
199
+ */
200
+ nominative: string;
201
+ /**
202
+ * Full Latin phrasing in the Accusative case (e.g. `"Kalendas Januarias"`, `"ante diem XVII Kalendas Novembres"`).
203
+ */
204
+ accusative: string;
205
+ /**
206
+ * Full Latin phrasing in the Ablative case (e.g. `"Kalendis Januariis"`, `"Idibus Martiis"`).
207
+ */
208
+ ablative: string;
209
+ /**
210
+ * Formats this classical date according to specified options.
211
+ */
212
+ format(options?: RomanFormatOptions): string;
213
+ }
214
+ /**
215
+ * Static namespace exposed on `Tempo.roman`.
216
+ */
217
+ export interface RomanNamespace {
218
+ /**
219
+ * Calculates the classical Roman date representation for a given date, Tempo instance, or object.
220
+ */
221
+ toClassical(date: Tempo | Date | {
222
+ year: number;
223
+ month: number;
224
+ day: number;
225
+ }, options?: RomanCalculationOptions): ClassicalRomanDate;
226
+ /**
227
+ * Formats a date using classical Roman calendar conventions and format options.
228
+ */
229
+ format(date: Tempo | Date | {
230
+ year: number;
231
+ month: number;
232
+ day: number;
233
+ }, options?: RomanFormatOptions): string;
234
+ /**
235
+ * Converts an astronomical or historical year into an Ab Urbe Condita (AUC) year.
236
+ *
237
+ * @param year - Astronomical year (e.g. 2026, 0 for 1 BCE, -43 for 44 BCE) or positive BCE year when era is specified.
238
+ * @param era - Optional era indicator (`'CE'` or `'BCE'`).
239
+ * @returns The year in AUC reckoning.
240
+ */
241
+ yearToAuc(year: number, era?: 'CE' | 'BCE'): number;
242
+ /**
243
+ * Converts an Ab Urbe Condita (AUC) year into an astronomical or historical year.
244
+ *
245
+ * @param auc - AUC year number (e.g. 2779 AUC).
246
+ * @param format - `'astronomical'` (default) or `'historical'` (`{ year, era }`).
247
+ */
248
+ aucToYear(auc: number, format?: 'astronomical'): number;
249
+ aucToYear(auc: number, format: 'historical'): {
250
+ year: number;
251
+ era: 'CE' | 'BCE';
252
+ };
253
+ aucToYear(auc: number, format?: 'astronomical' | 'historical'): number | {
254
+ year: number;
255
+ era: 'CE' | 'BCE';
256
+ };
257
+ /**
258
+ * Returns the day of the month for the Nones in a given month (7 for March, May, July, October; 5 otherwise).
259
+ */
260
+ getNonesDay(month: number): number;
261
+ /**
262
+ * Returns the day of the month for the Ides in a given month (15 for March, May, July, October; 13 otherwise).
263
+ */
264
+ getIdesDay(month: number): number;
265
+ /**
266
+ * Evaluates whether a year is a leap year under Julian or Gregorian reckoning.
267
+ */
268
+ isLeapYear(year: number, isJulian?: boolean): boolean;
269
+ /**
270
+ * Parses a classical Latin date expression (e.g. `'a.d. IV Id. Mart. 710 AUC'`) into a Tempo instance.
271
+ *
272
+ * @throws {RangeError} if the expression is not a recognisable, real date
273
+ */
274
+ parse(input: string, options?: RomanParseOptions): Tempo;
275
+ /**
276
+ * Parses a classical Latin date expression into its calendar components without creating a Tempo.
277
+ *
278
+ * @throws {RangeError} if the expression is not a recognisable, real date
279
+ */
280
+ parseDate(input: string, options?: RomanParseOptions): ParsedRomanDate;
281
+ /**
282
+ * Resolves a classical Roman date structure back into calendar year, month, and day.
283
+ */
284
+ fromClassical(anchor: RomanAnchor, anchorMonth: number, anchorYear: number, relation: RomanDateRelation, count?: number, isBissextile?: boolean, isJulian?: boolean, bissextile?: boolean): {
285
+ year: number;
286
+ month: number;
287
+ day: number;
288
+ };
289
+ /**
290
+ * Retrieves the list of eponymous Roman consuls for an astronomical year from the Fasti (509 BCE–541 CE).
291
+ *
292
+ * @param year - Astronomical year (0 = 1 BCE, -62 = 63 BCE, 541 = 541 CE)
293
+ * @returns Array of consul names, or undefined if no ordinary consuls are recorded
294
+ */
295
+ getConsuls(year: number): readonly string[] | undefined;
296
+ /**
297
+ * Formats the eponymous Roman consuls of an astronomical year into a classical Latin dating formula.
298
+ *
299
+ * @param year - Astronomical year
300
+ * @param style - `'ablative'` (default, e.g. `"Cicerone et Antonio coss."`) or `'nominative'`
301
+ * @returns Formatted formula or undefined if no entry exists
302
+ */
303
+ formatConsuls(year: number, style?: ConsularFormatStyle): string | undefined;
304
+ /**
305
+ * Searches the Fasti consulares for matching consul names.
306
+ *
307
+ * @param query - Case-insensitive name substring
308
+ * @returns List of matching years and consul pairs
309
+ */
310
+ findConsuls(query: string): ConsularPair[];
311
+ /**
312
+ * Registers an external consular catalog into the active catalog.
313
+ *
314
+ * @param catalog - Mapping of astronomical years to arrays of consul names
315
+ */
316
+ registerConsuls(catalog: Record<number, readonly string[]>): void;
317
+ }
package/package.json CHANGED
@@ -1,6 +1,76 @@
1
1
  {
2
2
  "name": "@tempo-kit/plugin-roman",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.0.0-rc.0",
4
+ "description": "Tempo community plugin for classical Roman calendar arithmetic (Kalends, Nones, Ides, Ante Diem), leap year bissextile handling, and AUC (Ab Urbe Condita) year conversions.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "sideEffects": [
8
+ "./dist/install.js",
9
+ "./dist/consuls.js"
10
+ ],
11
+ "license": "MIT",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/magmacomputing/magma.git",
15
+ "directory": "packages/plugins/roman"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "README.md",
20
+ "CHANGELOG.md",
21
+ "LICENSE"
22
+ ],
23
+ "publishConfig": {
24
+ "registry": "https://registry.npmjs.org/",
25
+ "access": "public"
26
+ },
27
+ "scripts": {
28
+ "build": "tsup && tsc",
29
+ "test": "vitest run -c ../vitest.shared.ts",
30
+ "prepublishOnly": "tempo-cli prepublish"
31
+ },
32
+ "peerDependencies": {
33
+ "tempo-kit": "^5.0.0"
34
+ },
35
+ "devDependencies": {
36
+ "tempo-kit": "^5.0.0"
37
+ },
38
+ "keywords": [
39
+ "tempo-kit",
40
+ "tempo-kit-plugin",
41
+ "tempo",
42
+ "temporal",
43
+ "tempo-plugin",
44
+ "plugin",
45
+ "roman",
46
+ "roman-calendar",
47
+ "kalends",
48
+ "nones",
49
+ "ides",
50
+ "ante-diem",
51
+ "bissextile",
52
+ "auc",
53
+ "ab-urbe-condita",
54
+ "classical-antiquity",
55
+ "latin",
56
+ "typescript"
57
+ ],
58
+ "type": "module",
59
+ "exports": {
60
+ ".": {
61
+ "types": "./dist/index.d.ts",
62
+ "import": "./dist/index.js",
63
+ "default": "./dist/index.js"
64
+ },
65
+ "./consuls": {
66
+ "types": "./dist/consuls.d.ts",
67
+ "import": "./dist/consuls.js",
68
+ "default": "./dist/consuls.js"
69
+ },
70
+ "./install": {
71
+ "types": "./dist/install.d.ts",
72
+ "import": "./dist/install.js",
73
+ "default": "./dist/install.js"
74
+ }
75
+ }
76
+ }