@@ -5,13 +5,16 @@ import {
55 StringUnitLength ,
66 ToISOFormat ,
77 ToISOTimeDurationOptions ,
8+ WeekSettings ,
89 ZoneOptions ,
910} from "../index" ;
1011import { CanBeInvalid , DefaultValidity , IfValid , Invalid , Valid } from "./_util" ;
1112import { Duration , DurationLike , DurationUnits } from "./duration" ;
1213import { Interval } from "./interval" ;
1314import { Zone } from "./zone" ;
1415
16+ export { } ; // Turn off default exports
17+
1518export type DateTimeUnit = "year" | "quarter" | "month" | "week" | "day" | "hour" | "minute" | "second" | "millisecond" ;
1619export type ToRelativeUnit = "years" | "quarters" | "months" | "weeks" | "days" | "hours" | "minutes" | "seconds" ;
1720
@@ -304,6 +307,7 @@ export interface LocaleOptions {
304307 locale ?: string | undefined ;
305308 outputCalendar ?: CalendarSystem | undefined ;
306309 numberingSystem ?: NumberingSystem | undefined ;
310+ weekSettings ?: WeekSettings | undefined ;
307311}
308312
309313export type ResolvedLocaleOptions = Required < LocaleOptions > ;
@@ -397,6 +401,11 @@ export interface ExplainedFormat {
397401
398402export type DateTimeMaybeValid = CanBeInvalid extends true ? ( DateTime < Valid > | DateTime < Invalid > ) : DateTime ;
399403
404+ declare const tokenParserBrand : unique symbol ;
405+ export interface TokenParser {
406+ [ tokenParserBrand ] : true ;
407+ }
408+
400409/**
401410 * A DateTime is an immutable data structure representing a specific date and time and accompanying methods.
402411 * It contains class and instance methods for creating, parsing, interrogating, transforming, and formatting them.
@@ -1616,6 +1625,25 @@ export class DateTime<IsValid extends boolean = DefaultValidity> {
16161625 */
16171626 static fromStringExplain ( text : string , fmt : string , options ?: DateTimeOptions ) : ExplainedFormat ;
16181627
1628+ /**
1629+ * Build a parser for fmt using the given locale. This parser can be passed to {@link DateTime.fromFormatParser} to a parse a date in this format. This can be used to optimize cases where many dates need to be parsed in a specific format.
1630+ *
1631+ * @param fmt - the format the string is expected to be in (see description)
1632+ * @param options - the Locale options
1633+ */
1634+ static buildFormatParser ( fmt : string , options ?: LocaleOptions ) : TokenParser ;
1635+
1636+ /**
1637+ * Create a DateTime from an input string and format parser.
1638+ *
1639+ * The format parser must have been created with the same locale as this call.
1640+ *
1641+ * @param text the string to parse
1642+ * @param formatParser - parser from {@link DateTime.buildFormatParser}
1643+ * @param opts options taken by fromFormat()
1644+ */
1645+ static fromFormatParser ( text : string , formatParser : TokenParser , opts ?: DateTimeOptions ) : DateTimeMaybeValid ;
1646+
16191647 // FORMAT PRESETS
16201648
16211649 /**
0 commit comments