(options: DateOptions)
| 987 | * @since 4.0.0 |
| 988 | */ |
| 989 | export const Date = (options: DateOptions): Prompt<globalThis.Date> => { |
| 990 | const opts: DateOptionsReq = { |
| 991 | initial: new globalThis.Date(), |
| 992 | dateMask: "YYYY-MM-DD HH:mm:ss", |
| 993 | validate: Effect.succeed, |
| 994 | ...options, |
| 995 | locales: { |
| 996 | ...defaultLocales, |
| 997 | ...options.locales |
| 998 | } |
| 999 | } |
| 1000 | const dateParts = makeDateParts(opts.dateMask, opts.initial, opts.locales) |
| 1001 | const initialCursorPosition = dateParts.findIndex((part) => !part.isToken()) |
| 1002 | const initialState: DateState = { |
| 1003 | dateParts, |
| 1004 | typed: "", |
| 1005 | cursor: initialCursorPosition, |
| 1006 | value: opts.initial, |
| 1007 | error: Option.none() |
| 1008 | } |
| 1009 | return Custom(initialState, { |
| 1010 | render: handleDateRender(opts), |
| 1011 | process: handleDateProcess(opts), |
| 1012 | clear: handleDateClear(opts) |
| 1013 | }) |
| 1014 | } |
| 1015 | |
| 1016 | /** |
| 1017 | * Creates a file-system selection prompt and returns the selected path. |
nothing calls this directly
no test coverage detected