Fix invalid date error in Safari

Related to http://stackoverflow.com/q/4310953/3108885.

Fix #4.