bengourley / anytime

A date/time picker
http://bengourley.github.io/anytime/
22 stars 8 forks source link

Difficult interface for standard HTML forms #25

Open serby opened 9 years ago

serby commented 9 years ago

The human friendly date formats are not good for parsing.

I find myself having to do the follow to use anytime on a form.

input.js-timepicker(type='text', name='endDateView', data-control='endDate')
input(type='hidden', name='endDate', value=data.endDate)
  $('.js-timepicker').each(function (i, el) {
    var picker = new TimePicker({ input: el })
    picker.render()
    picker.on('change', function(date) {
      var $el = $('[name=' + $(el).data('control') + ']')
      if (date) {
        $el.val(date.toISOString())
      } else {
        $el.val()
      }
    })
  })

It would be nice if there was an easier way to achieve this.

bengourley commented 9 years ago

What do you think would be a good way to hook this up? Off the top of my head everything I can think of immediately gets opinionated.

arkon commented 9 years ago

Should the picker object itself contain a variable that contains the selected date as an ISO-8601 string?