DateTimePicker
DateTimePicker copied to clipboard
Add a way to set the picker's date to now
Here is what I have so far, but there is probably a better way:
afterShow: (elem) ->
oDTP = this
$picker = $('#post_published_at_picker')
$picker.find('.dtpicker-value')
.after('<div class="dtpicker-nowWrapper"><a class="dtpicker-buttonNow">change to now</a></div>')
$picker.find('.dtpicker-buttonNow').on 'click', ->
# TODO: allow now's time zone to be different than browser time zone
now = new Date()
oDTP.oData.iCurrentYear = now.getFullYear()
oDTP.oData.iCurrentMonth = now.getMonth()
oDTP.oData.iCurrentDay = now.getDate()
oDTP.oData.iCurrentHour = now.getHours()
oDTP.oData.iCurrentMinutes = now.getMinutes()
oDTP._setCurrentDate()
.dtpicker-nowWrapper {
text-align: center;
}