@tempo-kit/plugin-dialects 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/CHANGELOG.md +115 -0
- package/LICENSE +21 -0
- package/README.md +65 -2
- package/dist/compiler/dotnet.compiler.d.ts +28 -0
- package/dist/compiler/go.compiler.d.ts +28 -0
- package/dist/compiler/ldml.compiler.d.ts +28 -0
- package/dist/compiler/mysql.compiler.d.ts +21 -0
- package/dist/compiler/oracle.compiler.d.ts +39 -0
- package/dist/compiler/php.compiler.d.ts +30 -0
- package/dist/compiler/shared.compiler.d.ts +86 -0
- package/dist/compiler/sheet.compiler.d.ts +32 -0
- package/dist/compiler/strftime.compiler.d.ts +28 -0
- package/dist/constants.d.ts +54 -0
- package/dist/engine/convert.d.ts +14 -0
- package/dist/engine/dialect.registry.d.ts +40 -0
- package/dist/engine/dialect.shim.d.ts +4 -0
- package/dist/engine/explain.d.ts +13 -0
- package/dist/engine/export.d.ts +12 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.global.min.js +1 -0
- package/dist/index.js +5791 -0
- package/dist/install.d.ts +2 -0
- package/dist/install.global.min.js +1 -0
- package/dist/install.js +5794 -0
- package/dist/types.d.ts +152 -0
- package/package.json +70 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@tempo-kit/plugin-dialects` will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [2.0.0] - 2026-11-27
|
|
9
|
+
|
|
10
|
+
### Breaking Changes
|
|
11
|
+
- Migrated package namespace from `@magmacomputing/tempo-plugin-dialects` to `@tempo-kit/plugin-dialects`.
|
|
12
|
+
- Updated `peerDependencies` to `tempo-kit@^5.0.0`.
|
|
13
|
+
|
|
14
|
+
## [2.0.0] - 2026-11-27
|
|
15
|
+
|
|
16
|
+
### Breaking Changes
|
|
17
|
+
- Migrated package namespace from `@magmacomputing/tempo-plugin-dialects` to `@tempo-kit/plugin-dialects`.
|
|
18
|
+
- Updated `peerDependencies` to `tempo-kit@^5.0.0`.
|
|
19
|
+
|
|
20
|
+
## [1.1.2] - 2026-11-08
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
- **Calendar Week Token Alignment (`{ww}`, `{ww:raw}`)**:
|
|
24
|
+
- Updated Oracle `WW` and `FMWW` explain and export mappings (`explain.ts`, `export.ts`) to target Tempo v5's canonical `{ww}` and `{ww:raw}` calendar week tokens.
|
|
25
|
+
- Preserved `woy:cal`, `woy:cal:raw`, `ww:cal`, `ww:cal:raw`, `woy:jan1`, and `woy:jan1:raw` in `V4_EXPORT_ALIASES` for backward-compatible dialect export.
|
|
26
|
+
- Removed deprecated `{yw}` and `{wy}` (`wy:raw`, `wy:ord`) ISO-week aliases from `export.ts` to match the Tempo v5 core formatter.
|
|
27
|
+
- **Tempo v5.0.0 Guard & Peer Dependency Alignment**:
|
|
28
|
+
- Migrated internal nullish checks in `convert.ts` and `export.ts` to `!isNullish(...)`.
|
|
29
|
+
- Expanded `@magmacomputing/tempo` peer and dev dependencies to support `^4.7.0 || ^5.0.0`.
|
|
30
|
+
|
|
31
|
+
## [1.1.1] - 2026-10-29
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
- **Standardized Composable Offset Tokens (`{tz:offset:compact}`, `{offset:compact}`)**:
|
|
35
|
+
- Updated all dialect compilers (Go, MySQL, Oracle, PHP, Unicode LDML, .NET, spreadsheet, POSIX `strftime`), `explain()`, and `exportDialect()` to output standardized composable `{tz:offset:compact}` and `{offset:compact}` tokens, eliminating obsolete uncomposed `offsetcompact` modifiers.
|
|
36
|
+
- **Explain Engine Parity (`explain.ts`)**:
|
|
37
|
+
- Updated explain dictionaries for Go, PHP, LDML, Oracle, and strftime to map compact timezone offset specifiers (e.g. PHP `O`, Go `-0700`, `Z0700`, `-070000`, `Z070000`, and RFC 2822 `r`) directly to `{tz:offset:compact}`, `{tz:offset:compact:utc}`, and `{tz:offset:compact:ss}`.
|
|
38
|
+
- **Export Engine Backward Compatibility & Aliases (`export.ts`)**:
|
|
39
|
+
- Added canonical export mappings for `{tz:offset:compact}`, `{tz:offset:compact:ss}`, `{tz:offset:compact:utc}`, and `{tz:offset:compact:z}`.
|
|
40
|
+
- Added alias normalization in `V4_EXPORT_ALIASES` to ensure existing masks using legacy `{tz:offsetcompact}`, `{tz:offset:basic}`, `{tz:offsetcompact:ss}`, `{tz:offsetcompact:utc}`, and related permutations continue to export seamlessly.
|
|
41
|
+
- **Modular Plugin SDK Imports (`src/index.ts`)**:
|
|
42
|
+
- Decoupled internal `#library` imports (`isNull`), standardizing strictly on modular guards (`isFunction`, `isObject`) from `@magmacomputing/tempo/plugin/sdk`.
|
|
43
|
+
|
|
44
|
+
## [1.1.0] - 2026-10-21
|
|
45
|
+
|
|
46
|
+
### Added
|
|
47
|
+
- **Direct Dialect-to-Dialect Conversion (`convertDialect`)**:
|
|
48
|
+
- Added `convertDialect(mask, { from, to })`, `convertDialect(mask, from, to)`, and `convertDialect(mask, to)` with automatic source dialect detection.
|
|
49
|
+
- Mounted onto instance (`t.dialects.convert`) and static namespace (`Tempo.dialects.convert`).
|
|
50
|
+
- Returns structured `ConvertResult` tracking source, target, converted pattern, and any unmappable tokens.
|
|
51
|
+
- **Unified Options Object Signatures**:
|
|
52
|
+
- Added `{ dialect }` and `{ from, to }` options overloads to `explain(mask, options)`, `exportDialect(pattern, options)`, and `convertDialect(mask, options)`.
|
|
53
|
+
- Exported `ConvertOptions`, `ExplainOptions`, and `ExportOptions` interfaces.
|
|
54
|
+
- **Automatic Dialect Inference in Parsing**:
|
|
55
|
+
- `Tempo.fromFormat()`, `Tempo.fromFormats()`, and `Tempo.dialects.fromFormats()` automatically infer the dialect using `detectDialect(mask)` when omitted.
|
|
56
|
+
- Exported `detectDialect` helper from the package entry point.
|
|
57
|
+
- **Extended Token Transpilation & Dialect Gap Closures (Phases 2, 3, 4 & 5)**:
|
|
58
|
+
- Added Moment.js translation parity (`DDDD`/`DDD` for day of year, `WW`/`W` for ISO week, and `GGGG`/`gggg`/`GG`/`gg` for ISO week-numbering year, eliminating the LDML era collision).
|
|
59
|
+
- Added Unicode LDML quarter formatting and parsing support (`Q`, `QQ`, `QQQ`, `QQQQ`), cleanly defaulting parsed quarters to the start month of the quarter.
|
|
60
|
+
- Added export parity for 0-indexed weekday (`{dow:0}` / `{dow:zero}` mapping to PHP `w` and Moment `d`).
|
|
61
|
+
- Full explain, export, and cross-dialect conversion for Phase 4 specialized tokens:
|
|
62
|
+
- Oracle `J` ↔ `{jj}` (astronomic Julian day).
|
|
63
|
+
- Oracle `SSSSS` / `FMSSSSS` ↔ `{ss:day:5}` / `{ss:day:raw}` (seconds past midnight).
|
|
64
|
+
- Oracle `WW` / `FMWW` ↔ `{woy:cal}` / `{woy:cal:raw}` (calendar week starting Jan 1).
|
|
65
|
+
- Oracle `W` / `FMW` & Unicode LDML `W` ↔ `{wom}` (week of month).
|
|
66
|
+
- PHP `t` ↔ `{dim}` (days in month).
|
|
67
|
+
- PHP `z` ↔ `{dd:year:raw:0}` (0-indexed day of year).
|
|
68
|
+
- POSIX `%C` ↔ `{cen}` (century).
|
|
69
|
+
- POSIX `%w` ↔ `{dow:0}` (0-indexed weekday with Sunday as 0).
|
|
70
|
+
- Full reverse export mappings for numeric tail slicing (`{yow:short}`, `{yow:-2}`, `{yow:-3}`, `{yyyy:-3}`, `{yyyy:-1}`) and space padding (`{dd:space}`, `{doy:space}`, `{hh:space}`, `{h12:space}`).
|
|
71
|
+
- Full explain and export mappings for granular timezone offsets: `{tz:offset:hh}` (Oracle `TZH`, Go `-07`), `{tz:offset:mi}` (Oracle `TZM`), `{tz:offset:ss}` / `{tz:offsetcompact:ss}` (Go `-07:00:00`, `-070000`), and UTC `Z` indicators `{tz:offset:z}` / `{tz:offsetcompact:z}` (Go `Z07:00`, `Z0700`, `Z07`, `Z07:00:00`, `Z070000`).
|
|
72
|
+
- **Oracle / SQL TO_CHAR Format Dialect**:
|
|
73
|
+
- Full support for Oracle, PostgreSQL, Snowflake, and AWS Redshift date/time format models (`TO_CHAR`, `TO_DATE`, `TO_TIMESTAMP`).
|
|
74
|
+
- Added `DIALECT.Oracle = 'oracle'` to `DIALECT` enum.
|
|
75
|
+
- Added ecosystem aliases in `DIALECT_ALIAS`: `'sql'`, `'postgres'`, `'postgresql'`, `'snowflake'`, `'redshift'`, `'to_char'`, and `'tochar'`.
|
|
76
|
+
- Added dedicated instance helpers `t.dialects.oracle(mask)` and `t.dialects.sql(mask)`.
|
|
77
|
+
- Added `formatOracle` and `parseOracle` compiler engines with high-performance closure compilation and `WeakCache` memoization.
|
|
78
|
+
- Comprehensive token support:
|
|
79
|
+
- **Year**: `YYYY`, `RRRR` (with 2-digit pivot), `YYY`, `YY`, `RR`, `Y`, `IYYY` (ISO week-numbering year), `IYY`, `IY`, `I`.
|
|
80
|
+
- **Month**: `MM` (zero-padded), `MONTH` / `Month` / `month` (case-preserving full names), `MON` / `Mon` / `mon` (case-preserving abbreviations), and `RM` / `rm` (Roman numerals).
|
|
81
|
+
- **Day**: `DD`, `DDD` (day of year), `DAY` / `Day` / `day`, `DY` / `Dy` / `dy`, `D` (day of week), `J` (Julian day).
|
|
82
|
+
- **Time**: `HH24` (24-hour), `HH12` / `HH` (12-hour), `MI` (minutes), `SS` (seconds), `SSSSS` (seconds past midnight).
|
|
83
|
+
- **Subseconds**: `FF` and `FF1`-`FF9` (nanosecond-precision fractional seconds).
|
|
84
|
+
- **Meridiem**: `AM` / `PM`, `am` / `pm`, `A.M.` / `P.M.`, `a.m.` / `p.m.`.
|
|
85
|
+
- **Week & Quarter**: `IW` (ISO week), `WW` (week of year), `W` (week of month), `Q` (quarter).
|
|
86
|
+
- **Timezone**: `TZH:TZM`, `TZH`, `TZM`, `TZR`, `TZD`, `OF`.
|
|
87
|
+
- **Modifiers & Literals**: `FM` (Fill Mode unpadded suppression), `FX` (format exact), and `"..."` double-quoted literal text preservation.
|
|
88
|
+
- Enhanced `explain(mask, dialect)` with Oracle format translation to native Tempo `{token}` masks.
|
|
89
|
+
|
|
90
|
+
## [1.0.3] - 2026-10-03
|
|
91
|
+
|
|
92
|
+
### Changed
|
|
93
|
+
- **Tempo 4.5.0 Compatibility**:
|
|
94
|
+
- Updated peer and development dependencies to require `@magmacomputing/tempo` `^4.5.0`.
|
|
95
|
+
- Refactored month parsing in `ldml.compiler.ts` and `strftime.compiler.ts` to utilize the safe `enums.MONTH.get()` registry API without unsafe type assertions.
|
|
96
|
+
|
|
97
|
+
## [1.0.2] - 2026-09-29
|
|
98
|
+
|
|
99
|
+
### Changed & Performance
|
|
100
|
+
- **WeakCache Memoization**:
|
|
101
|
+
- Upgraded `FORMAT_CACHE` and `PARSE_REGEX_CACHE` in `ldml.compiler.ts` to `WeakCache<string, FormatterFn>` and `WeakCache<string, RegExp>`.
|
|
102
|
+
- Upgraded `STRFTIME_FORMAT_CACHE` and `STRFTIME_PARSE_CACHE` in `strftime.compiler.ts` to `WeakCache`.
|
|
103
|
+
- Dynamically compiled format builder functions and parser regular expressions are now auto-pruned upon garbage collection, eliminating memory leaks when formatting or parsing ad-hoc and custom format strings.
|
|
104
|
+
|
|
105
|
+
## [1.0.0] - 2026-09-20
|
|
106
|
+
|
|
107
|
+
### Added
|
|
108
|
+
- Initial GA release of `@tempo-kit/plugin-dialects`.
|
|
109
|
+
- Support for **Unicode LDML / UTS #35** format masks (`yyyy-MM-dd HH:mm:ss.SSS`, `dd LLL yyyy`, etc.).
|
|
110
|
+
- Support for **POSIX `strftime`** format specifiers (`%Y-%m-%d %H:%M:%S`, `%B %d, %Y`, etc.).
|
|
111
|
+
- Support for **Moment.js / Day.js** format patterns (`YYYY-MM-DD`).
|
|
112
|
+
- Added `t.dialects` namespace providing `t.dialects.ldml()`, `t.dialects.strftime()`, and `t.dialects.format()`.
|
|
113
|
+
- Added `Tempo.dialects` static tools (`Tempo.dialects.parse()`, `Tempo.dialects.fromFormats()`).
|
|
114
|
+
- Added drop-in migration shims `t.toFormat()` and `Tempo.fromFormat()`.
|
|
115
|
+
- Zero-boilerplate auto-installation via `@tempo-kit/plugin-dialects/install`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Magma Computing
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,66 @@
|
|
|
1
|
-
|
|
1
|
+

|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# @tempo-kit/plugin-dialects
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/@tempo-kit/plugin-dialects"><img src="https://img.shields.io/npm/v/@tempo-kit/plugin-dialects?style=flat-square" alt="npm version" style="display: inline-block; margin: 0 4px;"></a> <a href="https://www.npmjs.com/package/tempo-kit"><img src="https://img.shields.io/npm/dependency-version/@tempo-kit/plugin-dialects/peer/tempo-kit?style=flat-square" alt="npm peer dependency version" style="display: inline-block; margin: 0 4px;"></a> <a href="https://www.npmjs.com/package/@tempo-kit/plugin-dialects"><img src="https://img.shields.io/npm/l/@tempo-kit/plugin-dialects?style=flat-square" alt="License" style="display: inline-block; margin: 0 4px;"></a> <a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-Ready-blue?logo=typescript&style=flat-square" alt="TypeScript Ready" style="display: inline-block; margin: 0 4px;"></a> <a href="https://magmacomputing.github.io/magma/doc/9-plugins/dialects.index.html"><img src="https://img.shields.io/badge/Docs-VitePress-brightgreen?logo=vitepress&style=flat-square" alt="Documentation" style="display: inline-block; margin: 0 4px;"></a>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
Community plugin for Tempo providing seamless support for external date formatting standards and library dialects, including **Unicode LDML / UTS #35 (Luxon, date-fns)**, **Moment.js / Day.js**, **POSIX `strftime` (C, Python)**, and **Oracle / SQL `TO_CHAR` (PostgreSQL, Snowflake, Redshift)**.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @tempo-kit/plugin-dialects
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
### 1. Explicit Registration (Recommended)
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { Tempo } from 'tempo-kit';
|
|
23
|
+
import { DialectsPlugin, DIALECT } from '@tempo-kit/plugin-dialects';
|
|
24
|
+
|
|
25
|
+
Tempo.use(DialectsPlugin);
|
|
26
|
+
|
|
27
|
+
const t = new Tempo('2026-10-24T15:30:45');
|
|
28
|
+
|
|
29
|
+
// 1. Unicode LDML / Luxon formatting
|
|
30
|
+
t.format('yyyy-MM-dd HH:mm:ss', { dialect: DIALECT.Ldml }); // "2026-10-24 15:30:45"
|
|
31
|
+
t.dialects.ldml('dd LLL yyyy'); // "24 Oct 2026"
|
|
32
|
+
t.toFormat('yyyy-MM-dd'); // Luxon drop-in alias
|
|
33
|
+
|
|
34
|
+
// 2. POSIX strftime formatting
|
|
35
|
+
t.format('%Y-%m-%d %H:%M:%S', { dialect: DIALECT.Strftime }); // "2026-10-24 15:30:45"
|
|
36
|
+
t.dialects.strftime('%B %d, %Y'); // "October 24, 2026"
|
|
37
|
+
|
|
38
|
+
// 3. Oracle / SQL TO_CHAR formatting (PostgreSQL, Snowflake, Redshift)
|
|
39
|
+
t.dialects.sql('YYYY-MM-DD HH24:MI:SS'); // "2026-10-24 15:30:45"
|
|
40
|
+
t.dialects.oracle('FMMonth DD, YYYY'); // "October 24, 2026"
|
|
41
|
+
t.format('YYYY-MM-DD HH24:MI:SS', { dialect: 'postgres' }); // "2026-10-24 15:30:45"
|
|
42
|
+
|
|
43
|
+
// 4. Dialect-based Parsing
|
|
44
|
+
Tempo.fromFormat('24/10/2026', 'dd/MM/yyyy');
|
|
45
|
+
Tempo.dialects.parse('2026-10-24 15:30:45', 'YYYY-MM-DD HH24:MI:SS', 'sql');
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
> ⚡ **[Try this live in the interactive Tempo Sandbox ↗](https://magmacomputing.github.io/magma/repl/index.html?plugin=dialects)**
|
|
49
|
+
|
|
50
|
+
### 2. Zero-Boilerplate Side-Effect Registration
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import '@tempo-kit/plugin-dialects/install';
|
|
54
|
+
import { Tempo } from 'tempo-kit';
|
|
55
|
+
|
|
56
|
+
const t = new Tempo('2026-10-24');
|
|
57
|
+
console.log(t.toFormat('yyyy-MM-dd'));
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Documentation
|
|
61
|
+
|
|
62
|
+
📖 **[Read the Official Dialects Plugin Documentation](https://magmacomputing.github.io/magma/doc/9-plugins/dialects.index.html)**
|
|
63
|
+
|
|
64
|
+
## Licensing
|
|
65
|
+
|
|
66
|
+
This is a **Community** plugin. It is completely free and open-source for personal and commercial use.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ValueOf } from 'tempo-kit/plugin/sdk';
|
|
2
|
+
import type { FormatterFn, DialectOptions } from './shared.compiler.js';
|
|
3
|
+
export declare const DOTNET_TOKENS: readonly ["fffffff", "ffffff", "fffff", "ffff", "fff", "ff", "f", "FFFFFFF", "FFFFFF", "FFFFF", "FFFF", "FFF", "FF", "F", "yyyyy", "yyyy", "yyy", "yy", "y", "MMMM", "MMM", "MM", "M", "dddd", "ddd", "dd", "d", "HH", "H", "hh", "h", "mm", "m", "ss", "s", "tt", "t", "zzz", "zz", "z", "K", "gg", "g"];
|
|
4
|
+
export type DotNetSpecifier = ValueOf<typeof DOTNET_TOKENS>;
|
|
5
|
+
/**
|
|
6
|
+
* Unescapes backslash-escaped characters within .NET quoted string literals.
|
|
7
|
+
*/
|
|
8
|
+
export declare function unescapeDotNetQuoted(literal: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Normalizes a .NET format mask by resolving standard single-character specifiers.
|
|
11
|
+
*/
|
|
12
|
+
export declare function normalizeDotNetMask(mask: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Compiles a .NET format mask into a high-performance formatter function.
|
|
15
|
+
*/
|
|
16
|
+
export declare function compileDotNetFormatter(rawMask: string): FormatterFn;
|
|
17
|
+
/**
|
|
18
|
+
* Formats a date using .NET custom or standard format specifiers.
|
|
19
|
+
*/
|
|
20
|
+
export declare function formatDotNet(zdt: Temporal.ZonedDateTime, mask: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Compiles a .NET format mask into a parsing RegExp.
|
|
23
|
+
*/
|
|
24
|
+
export declare function compileDotNetParser(rawMask: string): RegExp;
|
|
25
|
+
/**
|
|
26
|
+
* Parses an input string using a .NET custom or standard format mask.
|
|
27
|
+
*/
|
|
28
|
+
export declare function parseDotNet(input: string, mask: string, options?: DialectOptions): Temporal.ZonedDateTime | undefined;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type FormatterFn, type DialectOptions } from './shared.compiler.js';
|
|
2
|
+
export declare const GO_TOKEN_REGEX: RegExp;
|
|
3
|
+
/**
|
|
4
|
+
* Compiles a Go reference time format mask into a formatter function.
|
|
5
|
+
* Fractional layouts with zeros keep their width; layouts with nines trim trailing zeros and omit an empty fraction.
|
|
6
|
+
* Month and weekday names are English; an unavailable zone abbreviation falls back to the zone identifier.
|
|
7
|
+
*/
|
|
8
|
+
export declare function compileGoFormatter(mask: string): FormatterFn;
|
|
9
|
+
/**
|
|
10
|
+
* Formats a Temporal.ZonedDateTime using a Go reference time format mask.
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatGo(temporal: Temporal.ZonedDateTime, mask: string, _options?: any): string;
|
|
13
|
+
/**
|
|
14
|
+
* Compiles a Go reference format mask into a regular expression for parsing.
|
|
15
|
+
*/
|
|
16
|
+
export declare function compileGoParser(mask: string): RegExp;
|
|
17
|
+
/**
|
|
18
|
+
* Parses an input string using a Go reference format mask into a Temporal.ZonedDateTime.
|
|
19
|
+
* Matching is case-insensitive without trimming input. Missing date fields default to the reference year, January,
|
|
20
|
+
* and day 1; missing time fields default to zero. Two-digit years 00-68 mean 2000-2068 and 69-99 mean 1969-1999.
|
|
21
|
+
*
|
|
22
|
+
* @param options - `today` supplies the reference year; otherwise uses the current date in the resolved zone.
|
|
23
|
+
* Parsed offsets or zone names override `timeZone` (default UTC); `calendar` defaults to iso8601.
|
|
24
|
+
* Abbreviations like PDT may not be valid Temporal time zone identifiers and can be rejected during parsing.
|
|
25
|
+
* @returns The parsed date-time, or undefined for a mismatch, conflicting day-of-year fields, nonzero offset seconds,
|
|
26
|
+
* or rejected date/time fields. Temporal construction errors are caught and return undefined.
|
|
27
|
+
*/
|
|
28
|
+
export declare function parseGo(input: string, mask: string, options?: DialectOptions): Temporal.ZonedDateTime | undefined;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ValueOf } from 'tempo-kit/plugin/sdk';
|
|
2
|
+
import { type FormatterFn, type DialectOptions } from './shared.compiler.js';
|
|
3
|
+
export declare const LDML_TOKENS: readonly ["ZZZZZ", "yyyy", "YYYY", "MMMM", "LLLL", "EEEE", "cccc", "GGGG", "ZZZZ", "zzzz", "SSSSSSSSS", "SSSSSSSS", "SSSSSSS", "SSSSSS", "SSSSS", "SSSS", "SSS", "SS", "S", "MMM", "LLL", "EEE", "ccc", "EE", "QQQQ", "qqqq", "QQQ", "qqq", "GGG", "ZZZ", "zzz", "yy", "YY", "MM", "LL", "dd", "HH", "hh", "kk", "mm", "ss", "aaa", "aa", "Do", "do", "ww", "II", "QQ", "qq", "GG", "ZZ", "zz", "cc", "ee", "DDDo", "DDD", "DD", "y", "Y", "M", "L", "d", "D", "G", "H", "h", "k", "m", "s", "a", "c", "e", "E", "w", "W", "Q", "q", "Z", "z", "I"];
|
|
4
|
+
export type LdmlToken = ValueOf<typeof LDML_TOKENS>;
|
|
5
|
+
/**
|
|
6
|
+
* Compiles an LDML format mask into a high-performance string builder.
|
|
7
|
+
*/
|
|
8
|
+
export declare function compileLdmlFormatter(mask: string): FormatterFn;
|
|
9
|
+
/**
|
|
10
|
+
* Formats a date using an LDML mask.
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatLdml(zdt: Temporal.ZonedDateTime, mask: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Compiles an LDML mask into a parsing RegExp with named capture groups.
|
|
15
|
+
*/
|
|
16
|
+
export declare function compileLdmlParser(mask: string): RegExp;
|
|
17
|
+
/**
|
|
18
|
+
* Parses an input string with an LDML mask.
|
|
19
|
+
* Input is trimmed and matching is case-insensitive. Missing time fields default to zero.
|
|
20
|
+
* For calendar date masks, an explicit year defaults missing month/day to January 1;
|
|
21
|
+
* an explicit month defaults missing day to 1. Two-digit years use a sliding pivot window based on the reference date (pivot default 75).
|
|
22
|
+
*
|
|
23
|
+
* @param options - `today` supplies missing date fields; otherwise uses the current date in the resolved zone.
|
|
24
|
+
* Parsed offsets or zone names override `timeZone` (default UTC); `calendar` defaults to iso8601.
|
|
25
|
+
* @returns The parsed date-time, or undefined for a mismatch or rejected fields.
|
|
26
|
+
* Temporal construction errors, including invalid time zones or calendars, are caught and return undefined.
|
|
27
|
+
*/
|
|
28
|
+
export declare function parseLdml(input: string, mask: string, options?: DialectOptions): Temporal.ZonedDateTime | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ValueOf } from 'tempo-kit/plugin/sdk';
|
|
2
|
+
import { type FormatterFn, type DialectOptions } from './shared.compiler.js';
|
|
3
|
+
export declare const MYSQL_SPECIFIERS: readonly ["%", "Y", "y", "m", "c", "M", "b", "d", "e", "D", "H", "k", "h", "I", "l", "i", "s", "S", "f", "p", "r", "T", "W", "a", "w", "j", "v", "x", "u", "U", "V", "X"];
|
|
4
|
+
export type MysqlSpecifier = ValueOf<typeof MYSQL_SPECIFIERS>;
|
|
5
|
+
export declare const MYSQL_SPECIFIER_REGEX: RegExp;
|
|
6
|
+
/**
|
|
7
|
+
* Compiles a MySQL DATE_FORMAT format mask into a high-performance formatter function.
|
|
8
|
+
*/
|
|
9
|
+
export declare function compileMysqlFormatter(mask: string): FormatterFn;
|
|
10
|
+
/**
|
|
11
|
+
* Formats a date using a MySQL DATE_FORMAT mask.
|
|
12
|
+
*/
|
|
13
|
+
export declare function formatMysql(zdt: Temporal.ZonedDateTime, mask: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Compiles a MySQL DATE_FORMAT mask into a parsing RegExp with named capture groups.
|
|
16
|
+
*/
|
|
17
|
+
export declare function compileMysqlParser(mask: string): RegExp;
|
|
18
|
+
/**
|
|
19
|
+
* Parses an input string using a MySQL DATE_FORMAT mask.
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseMysql(input: string, mask: string, options?: DialectOptions): Temporal.ZonedDateTime | undefined;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ValueOf } from 'tempo-kit/plugin/sdk';
|
|
2
|
+
import { type FormatterFn, type DialectOptions } from './shared.compiler.js';
|
|
3
|
+
export declare const ORACLE_TOKENS: readonly ["TZH:TZM", "HH24", "HH12", "SSSSS", "MONTH", "IYYY", "YYYY", "RRRR", "A.M.", "P.M.", "MON", "YYY", "IYY", "TZD", "TZR", "TZH", "TZM", "DAY", "DDTH", "DDD", "FM", "FX", "IW", "WW", "YY", "RR", "IY", "MM", "DD", "DY", "HH", "MI", "SS", "AM", "PM", "RM", "OF", "D", "W", "Q", "Y", "I", "J"];
|
|
4
|
+
export type OracleToken = ValueOf<typeof ORACLE_TOKENS>;
|
|
5
|
+
export declare const ORACLE_TOKEN_REGEX: RegExp;
|
|
6
|
+
/**
|
|
7
|
+
* Compiles an Oracle/PostgreSQL SQL format model into a fast formatter function.
|
|
8
|
+
* Double quotes delimit literals. FM toggles padding for supported numeric fields; FX emits no text.
|
|
9
|
+
* Month and weekday names are English and follow token casing; FF defaults to six fractional digits.
|
|
10
|
+
*/
|
|
11
|
+
export declare function compileOracleFormatter(mask: string): FormatterFn;
|
|
12
|
+
/**
|
|
13
|
+
* Formats a date using the Oracle/SQL TO_CHAR format dialect.
|
|
14
|
+
*/
|
|
15
|
+
export declare function formatOracle(zdt: Temporal.ZonedDateTime, mask: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Format tokens supported by formatOracle but unsupported for reverse parsing in parseOracle:
|
|
18
|
+
* YYY, IYY, IY, Y, I, J, W, Q, WW, SSSSS, TZH, TZM.
|
|
19
|
+
*/
|
|
20
|
+
export declare const ORACLE_UNSUPPORTED_PARSE_TOKENS: ReadonlySet<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Compiles an Oracle format model into a regular expression for parsing.
|
|
23
|
+
* Returns undefined if the mask contains unsupported reverse-parse tokens.
|
|
24
|
+
* Matching is anchored and case-insensitive; FM and FX do not change parsing strictness.
|
|
25
|
+
*/
|
|
26
|
+
export declare function compileOracleParser(mask: string): RegExp | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Parses trimmed input with an Oracle TO_CHAR / TO_DATE format model.
|
|
29
|
+
* Missing year uses the reference year; an explicit year defaults missing month/day to January 1,
|
|
30
|
+
* and an explicit month defaults missing day to 1. Missing time fields default to zero.
|
|
31
|
+
* YY uses the reference century. RR uses the previous century for 50-99 when the reference year ends in 00-49,
|
|
32
|
+
* or the next century for 00-49 when it ends in 50-99; otherwise RR uses the reference century.
|
|
33
|
+
*
|
|
34
|
+
* @param options - `today` supplies date defaults and the year pivot; otherwise uses the current date in the resolved zone.
|
|
35
|
+
* Parsed offsets or zone names override `timeZone` (default UTC); `calendar` defaults to iso8601.
|
|
36
|
+
* @returns The parsed date-time, or undefined for a mismatch, unsupported parse token, or rejected fields.
|
|
37
|
+
* Temporal construction errors, including invalid time zones or calendars, are caught and return undefined.
|
|
38
|
+
*/
|
|
39
|
+
export declare function parseOracle(input: string, mask: string, options?: DialectOptions): Temporal.ZonedDateTime | undefined;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ValueOf } from 'tempo-kit/plugin/sdk';
|
|
2
|
+
import { type FormatterFn, type DialectOptions } from './shared.compiler.js';
|
|
3
|
+
export declare const PHP_TOKENS: readonly ["Y", "y", "o", "m", "n", "M", "F", "t", "d", "j", "S", "z", "l", "D", "N", "w", "W", "H", "G", "h", "g", "i", "s", "v", "u", "a", "A", "O", "P", "T", "e", "U", "c", "r"];
|
|
4
|
+
export type PhpToken = ValueOf<typeof PHP_TOKENS>;
|
|
5
|
+
/**
|
|
6
|
+
* Compiles a PHP date format mask into a high-performance formatter function.
|
|
7
|
+
* A backslash makes the next character literal; unrecognized characters are retained.
|
|
8
|
+
* Month and weekday names are English; an unavailable zone abbreviation falls back to the zone identifier.
|
|
9
|
+
*/
|
|
10
|
+
export declare function compilePhpFormatter(mask: string): FormatterFn;
|
|
11
|
+
/**
|
|
12
|
+
* Formats a Temporal.ZonedDateTime using a PHP date format mask.
|
|
13
|
+
*/
|
|
14
|
+
export declare function formatPhp(temporal: Temporal.ZonedDateTime, mask: string, _options?: any): string;
|
|
15
|
+
/**
|
|
16
|
+
* Compiles a PHP date format mask into a regular expression for parsing.
|
|
17
|
+
*/
|
|
18
|
+
export declare function compilePhpParser(mask: string): RegExp;
|
|
19
|
+
/**
|
|
20
|
+
* Parses an input string using a PHP date format mask into a Temporal.ZonedDateTime.
|
|
21
|
+
* Matching is case-insensitive without trimming input. Missing date fields default to the reference year, January,
|
|
22
|
+
* and day 1; missing time fields default to zero. Two-digit years use a sliding pivot window based on the reference date (pivot default 75).
|
|
23
|
+
* `U` takes precedence over other date/time fields and denotes signed Unix seconds, producing an ISO calendar result.
|
|
24
|
+
*
|
|
25
|
+
* @param options - `today` supplies the reference year; otherwise uses the current date in the resolved zone.
|
|
26
|
+
* Parsed offsets or zone names override `timeZone` (default UTC); `calendar` defaults to iso8601 for non-epoch input.
|
|
27
|
+
* @returns The parsed date-time, or undefined for a mismatch or rejected fields, time zone, or calendar.
|
|
28
|
+
* Temporal construction errors are caught and return undefined.
|
|
29
|
+
*/
|
|
30
|
+
export declare function parsePhp(input: string, mask: string, options?: DialectOptions): Temporal.ZonedDateTime | undefined;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export type FormatterFn = (zdt: Temporal.ZonedDateTime) => string;
|
|
2
|
+
export interface DialectOptions {
|
|
3
|
+
dialect?: any;
|
|
4
|
+
timeZone?: any;
|
|
5
|
+
calendar?: any;
|
|
6
|
+
today?: Temporal.ZonedDateTime | undefined;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
export interface ParseContext {
|
|
10
|
+
tz: string;
|
|
11
|
+
today: Temporal.ZonedDateTime;
|
|
12
|
+
cal: string;
|
|
13
|
+
pivot: number;
|
|
14
|
+
}
|
|
15
|
+
export interface ParsedTime {
|
|
16
|
+
hour: number;
|
|
17
|
+
minute: number;
|
|
18
|
+
second: number;
|
|
19
|
+
}
|
|
20
|
+
export declare const REGEX_ESCAPE: RegExp;
|
|
21
|
+
export declare const REGEX_DOT: RegExp;
|
|
22
|
+
/** Escapes special regex characters in a literal string. */
|
|
23
|
+
export declare function escapeRegex(str: string): string;
|
|
24
|
+
/** Resolves an English month name or abbreviation to its month number. */
|
|
25
|
+
export declare function resolveMonth(str: string): number | undefined;
|
|
26
|
+
/** Resolves an English weekday name or abbreviation to its ISO weekday number (1 = Monday, 7 = Sunday). */
|
|
27
|
+
export declare function resolveWeekday(str: string): number | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Calculates the Sunday-based week of the year (00-53), where week 1 begins on the first Sunday.
|
|
30
|
+
* Days before the first Sunday of the year are considered week 0.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getSundayBasedWeek(_year: number, dayOfYear: number, dayOfWeek: number): number;
|
|
33
|
+
/** Creates a helper to extract named groups from a RegExpExecArray, including suffixed groups. */
|
|
34
|
+
export declare function createGroupExtractor(match: RegExpExecArray): (name: string) => string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Resolves parser defaults, preferring a parsed offset over a parsed zone name and `options.timeZone`.
|
|
37
|
+
* Defaults to UTC and the iso8601 calendar. Uses `options.today` as-is, or reads the current date in the resolved zone.
|
|
38
|
+
* Returns undefined if that current-date lookup fails or an offset includes nonzero seconds.
|
|
39
|
+
* A supplied `today` bypasses time zone validation here; calendar validation is left to the caller.
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveParseContext(getGroup: (name: string) => string | undefined, options?: DialectOptions): ParseContext | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Parses and validates hour, minute, second, and meridiem markers from matched groups.
|
|
44
|
+
* Missing fields default to zero. The `h24` range is 1-24; 24 becomes midnight without advancing the date.
|
|
45
|
+
* Returns undefined if any component is out of valid range.
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolveTimeComponents(getGroup: (name: string) => string | undefined): ParsedTime | undefined;
|
|
48
|
+
export interface ParsedDateFields {
|
|
49
|
+
year: number;
|
|
50
|
+
month: number;
|
|
51
|
+
day: number;
|
|
52
|
+
hour?: number;
|
|
53
|
+
minute?: number;
|
|
54
|
+
second?: number;
|
|
55
|
+
millisecond?: number;
|
|
56
|
+
microsecond?: number;
|
|
57
|
+
nanosecond?: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Constructs a Temporal.ZonedDateTime with the parsed Gregorian fields using the ISO calendar,
|
|
61
|
+
* then converts it to ctx.cal with withCalendar when needed.
|
|
62
|
+
* Returns undefined if date construction fails or overflow occurs.
|
|
63
|
+
*/
|
|
64
|
+
export declare function buildParsedZonedDateTime(fields: ParsedDateFields, ctx: ParseContext): Temporal.ZonedDateTime | undefined;
|
|
65
|
+
export interface ExtractedDateMetadata {
|
|
66
|
+
expectedDayOfWeek?: number | undefined;
|
|
67
|
+
expectedDayOfYear?: number | undefined;
|
|
68
|
+
expectedDaysInMonth?: number | undefined;
|
|
69
|
+
expectedQuarter?: number | undefined;
|
|
70
|
+
expectedIsoWeek?: number | undefined;
|
|
71
|
+
expectedIsoYear?: number | undefined;
|
|
72
|
+
expectedWeekU?: number | undefined;
|
|
73
|
+
expectedWeekW?: number | undefined;
|
|
74
|
+
expectedIsLeap?: number | undefined;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Validates auxiliary or redundant date fields against a resolved calendar date.
|
|
78
|
+
* Accepts either an existing Temporal.PlainDate or { year, month, day }.
|
|
79
|
+
* Returns false if date construction rejects (e.g. invalid day of month) or
|
|
80
|
+
* if any auxiliary field contradicts the resolved date.
|
|
81
|
+
*/
|
|
82
|
+
export declare function validateResolvedDateFields(date: Temporal.PlainDate | {
|
|
83
|
+
year: number;
|
|
84
|
+
month: number;
|
|
85
|
+
day: number;
|
|
86
|
+
}, meta: ExtractedDateMetadata): boolean;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ValueOf } from 'tempo-kit/plugin/sdk';
|
|
2
|
+
import type { FormatterFn, DialectOptions } from './shared.compiler.js';
|
|
3
|
+
export declare const SHEET_TOKENS: readonly ["mmmmm", "mmmm", "mmm", "mm", "m", "dddd", "ddd", "dd", "d", "yyyy", "yy", "hh", "h", "ss", "s", "AM/PM", "am/pm", "A/P", "a/p", ".000", ".00", ".0", "[h]", "[m]", "[s]"];
|
|
4
|
+
export type SheetSpecifier = ValueOf<typeof SHEET_TOKENS>;
|
|
5
|
+
/** @internal */
|
|
6
|
+
export interface SheetTokenMatch {
|
|
7
|
+
readonly type: 'literal' | 'token';
|
|
8
|
+
readonly value: string;
|
|
9
|
+
readonly raw?: string;
|
|
10
|
+
readonly isMinute?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Tokenizes a sheet mask into an intermediate array resolving ambiguous m/mm tokens into month vs minute.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare function tokenizeSheetMask(mask: string): SheetTokenMatch[];
|
|
17
|
+
/**
|
|
18
|
+
* Compiles an Excel / Google Sheets format mask into a high-performance formatter function.
|
|
19
|
+
*/
|
|
20
|
+
export declare function compileSheetFormatter(mask: string): FormatterFn;
|
|
21
|
+
/**
|
|
22
|
+
* Formats a date using Excel / Google Sheets format masks.
|
|
23
|
+
*/
|
|
24
|
+
export declare function formatSheet(zdt: Temporal.ZonedDateTime, mask: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Compiles a Sheet format mask into a parsing RegExp.
|
|
27
|
+
*/
|
|
28
|
+
export declare function compileSheetParser(mask: string): RegExp;
|
|
29
|
+
/**
|
|
30
|
+
* Parses an input string using an Excel / Google Sheets format mask.
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseSheet(input: string, mask: string, options?: DialectOptions): Temporal.ZonedDateTime | undefined;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ValueOf } from 'tempo-kit/plugin/sdk';
|
|
2
|
+
import { type FormatterFn, type DialectOptions } from './shared.compiler.js';
|
|
3
|
+
export declare const STRFTIME_SPECIFIERS: readonly ["%", "Y", "y", "C", "m", "B", "b", "h", "d", "e", "H", "I", "l", "k", "G", "g", "V", "U", "W", "D", "M", "S", "f", "p", "P", "A", "a", "w", "u", "j", "z", "Z", "F", "T", "R", "s"];
|
|
4
|
+
export type StrftimeSpecifier = ValueOf<typeof STRFTIME_SPECIFIERS>;
|
|
5
|
+
/**
|
|
6
|
+
* Compiles a POSIX strftime format string into a fast formatter function.
|
|
7
|
+
*/
|
|
8
|
+
export declare function compileStrftimeFormatter(mask: string): FormatterFn;
|
|
9
|
+
/**
|
|
10
|
+
* Formats a date using POSIX strftime specifiers.
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatStrftime(zdt: Temporal.ZonedDateTime, mask: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Compiles a strftime mask into a parsing RegExp.
|
|
15
|
+
*/
|
|
16
|
+
export declare function compileStrftimeParser(mask: string): RegExp;
|
|
17
|
+
/**
|
|
18
|
+
* Parses an input string with a POSIX strftime mask.
|
|
19
|
+
* Input is trimmed and matching is case-insensitive. Missing time fields default to zero.
|
|
20
|
+
* For calendar date masks, an explicit year defaults missing month/day to January 1;
|
|
21
|
+
* an explicit month defaults missing day to 1. Two-digit years use a sliding pivot window based on the reference date (pivot default 75).
|
|
22
|
+
*
|
|
23
|
+
* @param options - `today` supplies missing date fields; otherwise uses the current date in the resolved zone.
|
|
24
|
+
* Parsed offsets or zone names override `timeZone` (default UTC); `calendar` defaults to iso8601.
|
|
25
|
+
* @returns The parsed date-time, or undefined for a mismatch or rejected fields.
|
|
26
|
+
* Temporal construction errors, including invalid time zones or calendars, are caught and return undefined.
|
|
27
|
+
*/
|
|
28
|
+
export declare function parseStrftime(input: string, mask: string, options?: DialectOptions): Temporal.ZonedDateTime | undefined;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Enum } from 'tempo-kit/library';
|
|
2
|
+
import type { ValueOf, KeyOf } from 'tempo-kit/library';
|
|
3
|
+
/**
|
|
4
|
+
* ## DIALECT
|
|
5
|
+
* Canonical date formatting and parsing dialect identifiers.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DIALECT: Enum.wrap<{
|
|
8
|
+
Ldml: 'ldml';
|
|
9
|
+
Strftime: 'strftime';
|
|
10
|
+
Moment: 'moment';
|
|
11
|
+
Oracle: 'oracle';
|
|
12
|
+
Php: 'php';
|
|
13
|
+
Go: 'go';
|
|
14
|
+
Mysql: 'mysql';
|
|
15
|
+
DotNet: 'dotnet';
|
|
16
|
+
Sheet: 'sheet';
|
|
17
|
+
}>;
|
|
18
|
+
export type Dialect = ValueOf<typeof DIALECT>;
|
|
19
|
+
/**
|
|
20
|
+
* ## DIALECT_ALIAS
|
|
21
|
+
* Common ecosystem aliases mapped to canonical dialect identifiers.
|
|
22
|
+
*/
|
|
23
|
+
export declare const DIALECT_ALIAS: Enum.wrap<{
|
|
24
|
+
luxon: 'ldml';
|
|
25
|
+
datefns: 'ldml';
|
|
26
|
+
cldr: 'ldml';
|
|
27
|
+
posix: 'strftime';
|
|
28
|
+
c: 'strftime';
|
|
29
|
+
python: 'strftime';
|
|
30
|
+
dayjs: 'moment';
|
|
31
|
+
sql: 'oracle';
|
|
32
|
+
postgres: 'oracle';
|
|
33
|
+
postgresql: 'oracle';
|
|
34
|
+
snowflake: 'oracle';
|
|
35
|
+
redshift: 'oracle';
|
|
36
|
+
to_char: 'oracle';
|
|
37
|
+
tochar: 'oracle';
|
|
38
|
+
laravel: 'php';
|
|
39
|
+
wordpress: 'php';
|
|
40
|
+
golang: 'go';
|
|
41
|
+
mariadb: 'mysql';
|
|
42
|
+
csharp: 'dotnet';
|
|
43
|
+
'.net': 'dotnet';
|
|
44
|
+
'c#': 'dotnet';
|
|
45
|
+
spreadsheet: 'sheet';
|
|
46
|
+
excel: 'sheet';
|
|
47
|
+
sheets: 'sheet';
|
|
48
|
+
}>;
|
|
49
|
+
export type DialectAlias = KeyOf<typeof DIALECT_ALIAS>;
|
|
50
|
+
/**
|
|
51
|
+
* Normalizes a dialect name or alias to its canonical dialect identifier.
|
|
52
|
+
* Ignores surrounding whitespace and case; missing or unrecognized names resolve to LDML.
|
|
53
|
+
*/
|
|
54
|
+
export declare function normalizeDialect(input?: string): Dialect;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ConvertOptions, ConvertResult, DialectInput } from '../types.js';
|
|
2
|
+
export type { ConvertOptions };
|
|
3
|
+
/**
|
|
4
|
+
* Converts a format mask from one dialect directly into another dialect.
|
|
5
|
+
* If fromDialect is omitted, it will be automatically detected.
|
|
6
|
+
*
|
|
7
|
+
* @param mask - Format mask string in the source dialect
|
|
8
|
+
* @param fromOrToOrOptions - Source dialect name/alias, target dialect, or ConvertOptions object
|
|
9
|
+
* @param maybeToDialect - Target dialect name/alias (when fromDialect is explicitly provided)
|
|
10
|
+
* @returns A deeply frozen result whose string form is the converted pattern. `unsupported` lists distinct
|
|
11
|
+
* source tokens with empty Tempo mappings (except FM/FX), plus tokens or literals flagged during export.
|
|
12
|
+
* @throws Errors from evaluating source or target dialect suppliers propagate to the caller.
|
|
13
|
+
*/
|
|
14
|
+
export declare function convertDialect(mask: string, fromOrToOrOptions: DialectInput | ConvertOptions, maybeToDialect?: DialectInput): ConvertResult;
|