Skip to content

Commit

Permalink
Un-hardcoded the time fortmat
Browse files Browse the repository at this point in the history
Americans need to use MM/DD/YYY
  • Loading branch information
MeLlamoPablo committed Jan 4, 2017
1 parent 26870a5 commit 8f0913e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ module.exports = {
// List of accepted timezones: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
default_timezone: "Europe/Madrid",

// The time format that will be used for the create command. The bot will read a date string
// and will attempt to interpret it as the following format. If the passed time doesn't
// match the format, the command will result in an error.
//
// A list of valid format tokens can be found at:
// http://momentjs.com/docs/#year-month-and-day-tokens
time_format: "DD/MM/YYYY HH:mm",

// If this option is enabled, the bot will delete the message that triggered it, and its own
// response, after the specified amount of time has passed.
// Enable this if you don't want your channel to be flooded with bot messages.
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/general/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = new Clapp.Command({
date = moment.unix(argv.args.time);
} else {
// We got a date string
date = moment.tz(argv.args.time, "DD/MM/YYYY HH:mm", argv.flags.timezone);
date = moment.tz(argv.args.time, cfg.time_format, argv.flags.timezone);
}

if (!date.isValid()) {
Expand Down Expand Up @@ -49,7 +49,7 @@ module.exports = new Clapp.Command({
},
{
name: "time",
desc: "When the event will take place, in the format: DD/MM/YYYY HH:mm\n",
desc: "When the event will take place, in the format: " + cfg.time_format + "\n",
type: "string",
required: true
}
Expand Down

0 comments on commit 8f0913e

Please sign in to comment.