making sure that we ignore leading and trailing spaces

Provided format this kind of input `yyyy-mm-dd hh:ii` and input value `2013-10-09 ` (note the trailing space) will set date to `1899-12-31 00:00` instead of expected `2013-10-09 00:00`. This pull request fixes this.