-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: custom parser for relative date input (#53)
- Loading branch information
Showing
7 changed files
with
154 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import {settings as innerSettings} from './settings'; | ||
import type {PublicSettings} from './settings/types'; | ||
|
||
export const settings = innerSettings as PublicSettings; | ||
|
||
export {dateTime, dateTimeUtc, isDateTime} from './dateTime'; | ||
export {isValid} from './datemath'; | ||
export {dateTimeParse} from './parser'; | ||
export {parse as defaultRelativeParse, isLikeRelative as defaultIsLikeRelative} from './datemath'; | ||
export {dateTimeParse, isValid, isLikeRelative} from './parser'; | ||
export {getTimeZonesList, guessUserTimeZone, isValidTimeZone, timeZoneOffset} from './timeZone'; | ||
export type {DateTime, DateTimeInput} from './typings'; | ||
export {settings} from './settings'; | ||
export {UtcTimeZone} from './constants'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,29 @@ | ||
import type {ParseOptions} from '../datemath'; | ||
import type dayjs from '../dayjs'; | ||
import type {DateTime} from '../typings'; | ||
|
||
// https://dayjs.gitee.io/docs/ru/customization/customization | ||
export type UpdateLocaleConfig = Parameters<typeof dayjs.updateLocale>[1] | Partial<ILocale>; | ||
|
||
export interface Parser { | ||
parse: (text: string, options?: ParseOptions) => DateTime | undefined; | ||
isLikeRelative: (text: string) => boolean; | ||
} | ||
|
||
export interface PublicSettings { | ||
loadLocale(locale: string): Promise<void>; | ||
|
||
getLocale(): string; | ||
|
||
getLocaleData(): ILocale; | ||
|
||
setLocale(locale: string): void; | ||
|
||
updateLocale(config: UpdateLocaleConfig): void; | ||
|
||
setDefaultTimeZone(zone: 'system' | (string & {})): void; | ||
|
||
getDefaultTimeZone(): string; | ||
|
||
setRelativeParser(parser: Parser): void; | ||
} |