Skip to content

Instantly share code, notes, and snippets.

@DerekTBrown
Created August 2, 2017 21:36
Show Gist options
  • Save DerekTBrown/4b6b3357f3c0afbd87021e1c73762a42 to your computer and use it in GitHub Desktop.
Save DerekTBrown/4b6b3357f3c0afbd87021e1c73762a42 to your computer and use it in GitHub Desktop.
Datepicker Example w/Optional Time
/**
* Datetime prompt example
*/
'use strict';
var inquirer = require('inquirer');
// In your code, this will be:
inquirer.registerPrompt('datetime', require('inquirer-datepicker-prompt'))
var questions = [
{
type: 'datetime',
name: 'dt',
message: 'When is your birthday?',
format: ['m', '/', 'd', '/', 'yy'],
date: {
min: '1/1/2000'
},
time: {
min: '5:00 PM',
max: '10:00 PM',
minutes: {
interval: 15
}
}
}
];
inquirer.prompt(questions).then(function (answers) {
console.log(JSON.stringify(answers, null, ' '));
});
{
"name": "inquirer-datepicker-prompt-optional-time",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"author": "Derek Brown",
"license": "ISC",
"dependencies": {
"inquirer": "^3.2.1",
"inquirer-datepicker-prompt": "^0.3.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment