lightblue-platform / lightblue-core

Document based data access layer framework
GNU General Public License v3.0
32 stars 23 forks source link

Consider more flexible parsing of ISO 8601 dates [was: Consider using ISO 8601 formats for dates] #645

Open kahowell opened 8 years ago

kahowell commented 8 years ago

This would help with interoperability as ISO 8601 support is provided out of the box in at least Python, Ruby, and Java 8.

bserdar commented 8 years ago

The date format we use is 8601, isn't it:

20160505T10:23:44.216-0400

On Thu, May 5, 2016 at 9:31 AM, Kevin Howell notifications@github.com wrote:

This would help with interoperability as ISO 8601 support is provided out of the box in at least Python https://docs.python.org/2/library/datetime.html#datetime.datetime.isoformat, Ruby http://ruby-doc.org/stdlib-2.1.1/libdoc/time/rdoc/Time.html#method-c-iso8601, and Java 8 https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#ISO_LOCAL_DATE_TIME .

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/lightblue-platform/lightblue-core/issues/645

kahowell commented 8 years ago

I guess it is technically one variant of ISO-8601... though the more common conventions look like this:

2016-05-05T10:23:44.216-04:00

ISO-8601 has some flexbility in how certain components are specified... In Python, if you pass the timezone, you something like:

2016-05-05T14:03:48.262931-04:00

In Ruby you get:

2016-05-05T14:02:10-04:00

Looks like in Java 8 APIs, you get something like this:

2011-12-03T10:15:30+01:00

(Notice that Ruby and Java don't include sub-second information, at least not by default).

In my opinion, the most flexible thing would be to support parsing of all (or at least the most common) variants of ISO-8601... Specifically for the use case of receiving dates from a lightblue user. We could probably use a Date parsing library for this, such as this function in apache commons-lang. Alternatively, we could probably define a subset of ISO-8601 formats that we support (maybe something like full timestamp, timezone required, milliseconds or microseconds optional)?