Sunday, November 21, 2010

Dating yourself

After being dissatisfied with the complexity of JavaScript date widgets, I wrote this snippet to create a natural language solution, backed by the Datejs library.  It works by parsing the text a user entered on blur. 

It's a little rough at the moment, but a few refinements could make it just as effective as some of the more complicated implementations out there.
$('input.datefield').blur(function () {
  var field = $(this);
  var date = Date.parse(field.val());
  if (date) {
    field.val(date.toString("hh:mm tt"));
  }
});

Current Projects

SALi is short for sensor abstraction layer. The intent of SALi is to ease the development of sensor based applications by abstracting away both technical and social sensor management issues.

About Me

Previous Posts

Archives

Powered by Blogger