Skip to content

Instantly share code, notes, and snippets.

@mattn
Created January 28, 2009 10:24
Show Gist options
  • Save mattn/53887 to your computer and use it in GitHub Desktop.
Save mattn/53887 to your computer and use it in GitHub Desktop.
rfc822parse.js
alert(new Date("2009-01-28T19:26:31+09:00".replace(/^(\d+)[\-\/](\d+)[\-\/](\d+)T(\d+:\d+:\d+)([+\-].*)/, function() {
var r = RegExp;
return new Date(new Date([r.$1, r.$2, r.$3].join('/') + ' ' + r.$4 + ' ' + r.$5).getTime() +
+ parseInt(r.$5.replace(/^([\+\-])(\d+):(\d+)$/, function() {
var r = RegExp;
return r.$1 + (Number(r.$2)*3600 + Number(r.$3)*60);
}))).toString()
})).toString())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment