gr2m / moment-parseformat

A moment.js plugin to extract the format of a date/time string
http://gr2m.github.io/moment-parseformat
Apache License 2.0
45 stars 30 forks source link

Should be able to parse ISO-8601 Format #23

Closed tgrrtt closed 9 years ago

tgrrtt commented 9 years ago

There is currently only support for the following:

2014-02-02T10:11:58+00:00 → YYYY-MM-DDTHH:mm:ssZ

This does not have support for negative offset, or MS. Forthcoming PR with support for the following:

2014-09-04T01:20:28.888+02:00 → YYYY-MM-DDTHH:mm:ss.SSSZ
2014-09-04T01:20:28.888-02:00 → YYYY-MM-DDTHH:mm:ss.SSSZ
2014-02-02T10:11:58.888Z → YYYY-MM-DDTHH:mm:ss.SSSZ
gr2m commented 9 years ago

wanna try send a pull request to add it? I wonder if we can make it work without adding to much complexity to it

tgrrtt commented 9 years ago

I got something working, but then I realized that there's this behavior which complicates things a little bit ... https://github.com/gr2m/moment.parseFormat/issues/24

tgrrtt commented 9 years ago

Alternatively, that issue could be side-stepped by attempting to replace an ISO formatted Hours, Minutes, Seconds, and Ms first, like so /\d{2}:\d{2}:\d{2}\.\d{3}/ then attempt to replace other formats, so the current leading zero behavior could just stay the same.