terkelg/prompts

Fractional second part of a date type prompt has a non-responsive leading zero

kataik opened this issue · 0 comments

Describe the bug

When setting a date type prompt's format option to include the fractional seconds (e.g. YYYY-MM-DD HH:mm:ss.SSSS), the first digit is always zero (regardless of how many S is being used) and stays zero (can't change it). As a consequence, a format like HH:mm:ss.S will always have zero for milliseconds.

To Reproduce

Steps to reproduce the behavior:

import prompts from 'prompts';

async function foo() {
  return (
    await prompts({
      initial: new Date(),
      mask: 'YYYY-MM-DD HH:mm:ss.S',
      message: 'Try to set the milliseconds part to anything but 0!',
      name: 'value',
      type: 'date',
    })
  ).value;
}

foo().then(console.log);

Expected behavior

Expected the milliseconds section to change to something other than zero.

System

  • OS: MacOS 11.6.1
  • Terminal: iTerm
  • Node version: v14.16.1

Additional context

N/A