bevacqua / rome

:calendar: Customizable date (and time) picker. Opt-in UI, no jQuery!
https://bevacqua.github.io/rome
MIT License
2.91k stars 223 forks source link

Set default date / time #164

Open ajb opened 8 years ago

ajb commented 8 years ago

First off, thanks for the great library!

I'm writing on behalf of @jrubenoff (in https://github.com/dobtco/dispatch/issues/42), who asks: is there a configuration option for setting the default time to a certain hour of the day (e.g. 12am) instead of defaulting to the current time?

If not, would you be open to a PR? I could probably use a pointer to where in the code I should be looking, too.

Thanks for your time!

qmarcos commented 5 years ago

Yes, for example through setValue method.

var cal = rome(input);

// for example tomorrow at 8:00 AM through moment.js
var tomorrowat8am = moment().startOf('day').add(1, 'days').add(8, 'hours');

cal.setValue(tomorrowat8am);

Set value can receive different kind of formats, from the docs:

Forces a refresh of the calendar. This method will redraw the month and update the dates that can be selected in accordance with dateValidator and timeValidator.

Hope it helps!