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

Function date

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

Source from the content-addressed store, hash-verified

838 * @since 4.0.0
839 */
840export const date = (options: DateOptions): Prompt<Date> => {
841 const opts: Required<DateOptions> = {
842 initial: new Date(),
843 dateMask: "YYYY-MM-DD HH:mm:ss",
844 validate: Effect.succeed,
845 ...options,
846 locales: {
847 ...defaultLocales,
848 ...options.locales
849 }
850 }
851 const dateParts = makeDateParts(opts.dateMask, opts.initial, opts.locales)
852 const initialCursorPosition = dateParts.findIndex((part) => !part.isToken())
853 const initialState: DateState = {
854 dateParts,
855 typed: "",
856 cursor: initialCursorPosition,
857 value: opts.initial,
858 error: Option.none()
859 }
860 return custom(initialState, {
861 render: handleDateRender(opts),
862 process: handleDateProcess(opts),
863 clear: handleDateClear(opts)
864 })
865}
866
867/**
868 * 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