Created
August 2, 2017 21:36
-
-
Save DerekTBrown/4b6b3357f3c0afbd87021e1c73762a42 to your computer and use it in GitHub Desktop.
Datepicker Example w/Optional Time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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, ' ')); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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