Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Date filter should support ISO 8601 input #129

Merged
0 commits merged into from
Nov 9, 2010

Conversation

IgorMinar
Copy link
Contributor

date filter now supports input like 2009-12-31T23:00:00Z

I just wonder if we need to support input with milliseconds in the string too.

There is also a bunch of other fixes and improvements in this branch, please do not squash.

Closes #125

@groner
Copy link
Contributor

groner commented Nov 7, 2010

This looks good to me, Igor.

@IgorMinar
Copy link
Contributor Author

@groner I'm thinking about changing angular to use ISO 8601 timestamps as defined in Ecmascript 5 (Date#toISOString), which means that the timestamp string will include milliseconds. I think that you won't mind this change, but wanted to check.

@groner
Copy link
Contributor

groner commented Nov 7, 2010

As long they're optional, I don't see a problem with that.

@IgorMinar
Copy link
Contributor Author

Can you share more information about your use case? I wanted to keep it simple and wasn't planning on supporting both formats (with and without millis). What's the source of your ISO8601 formated string?

@groner
Copy link
Contributor

groner commented Nov 8, 2010

My immediate use, is to display a list of records in a table, one field is a timestamp (last login), I only want to show the date.

I can generate the timestamps with milliseconds if I need to.

From an interoperability stand point it would be nice to support variants that either don't include a "time-fraction" or have a different precision. These are valid, according to RFC-3339 (I haven't tried to find the actual ISO standard).

Edit: I am generating the strings with python's datetime.isoformat() method, which omits the time-fraction part of the string when the microsecond property is 0 (otherwise it uses six digits!).

@IgorMinar
Copy link
Contributor Author

ok, I made the time fractions optional for angular.String.toDate, which is used by the date filter.

@mhevery
Copy link
Contributor

mhevery commented Nov 8, 2010

One minor issue, LGTM otherwise. (squash to single CL.)

@johnnyelwailer
Copy link

The following dates won't get recognized by the date filter:
2012-06-18T13:06:34.4903392+02:00 and 1935-03-21T00:00:00
Are they not ISO? They are generated by Json.NET.
http://jsfiddle.net/johnnayweiler/rA3mn/2/

@groner
Copy link
Contributor

groner commented Jun 18, 2012

The date filter expects 3 decimal places for fractional seconds. It looks like there is already a patch (#989) to improve this.

The date without a timezone should be interpreted as Z, according to ES5. I created a new issue (#1073) for it.

You could use $provide.decorator() to make dateFilter work around these issues until they are fixed.

http://jsfiddle.net/rA3mn/3/

@pagebrooks
Copy link

@johnnyelwailer I ran into this problem as well. You can fix the issue by changing the Json.NET JsonSerializerSettings to output 3 decimal places. Here is an example: https://gist.github.com/4229693

This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants