(options: Prompt.Prompt.DateOptions)
| 284 | |
| 285 | /** @internal */ |
| 286 | export const date = (options: Prompt.Prompt.DateOptions): Prompt.Prompt<globalThis.Date> => { |
| 287 | const opts: Required<Prompt.Prompt.DateOptions> = { |
| 288 | initial: new Date(), |
| 289 | dateMask: "YYYY-MM-DD HH:mm:ss", |
| 290 | validate: Effect.succeed, |
| 291 | ...options, |
| 292 | locales: { |
| 293 | ...defaultLocales, |
| 294 | ...options.locales |
| 295 | } |
| 296 | } |
| 297 | const dateParts = makeDateParts(opts.dateMask, opts.initial, opts.locales) |
| 298 | const initialCursorPosition = dateParts.findIndex((part) => !part.isToken()) |
| 299 | const initialState: State = { |
| 300 | dateParts, |
| 301 | typed: "", |
| 302 | cursor: initialCursorPosition, |
| 303 | value: opts.initial, |
| 304 | error: Option.none() |
| 305 | } |
| 306 | return InternalPrompt.custom(initialState, { |
| 307 | render: handleRender(opts), |
| 308 | process: handleProcess(opts), |
| 309 | clear: handleClear(opts) |
| 310 | }) |
| 311 | } |
| 312 | |
| 313 | const DATE_PART_REGEX = |
| 314 | /\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g |
nothing calls this directly
no test coverage detected
searching dependent graphs…