MCPcopy Create free account
hub / github.com/Effect-TS/effect / Date

Function Date

packages/effect/src/cli/Prompt.ts:989–1014  ·  view source on GitHub ↗
(options: DateOptions)

Source from the content-addressed store, hash-verified

987 * @since 4.0.0
988 */
989export 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.

Callers

nothing calls this directly

Calls 6

makeDatePartsFunction · 0.85
handleDateRenderFunction · 0.85
handleDateProcessFunction · 0.85
handleDateClearFunction · 0.85
isTokenMethod · 0.80
CustomFunction · 0.70

Tested by

no test coverage detected