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

Function date

packages/cli/src/internal/prompt/date.ts:286–311  ·  view source on GitHub ↗
(options: Prompt.Prompt.DateOptions)

Source from the content-addressed store, hash-verified

284
285/** @internal */
286export 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
313const 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

Callers

nothing calls this directly

Calls 5

makeDatePartsFunction · 0.85
isTokenMethod · 0.80
handleRenderFunction · 0.70
handleProcessFunction · 0.70
handleClearFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…