New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISO string support on date pipes #3261

Closed
coryrylan opened this Issue Jul 24, 2015 · 12 comments

Comments

Projects
None yet
8 participants
@coryrylan
Contributor

coryrylan commented Jul 24, 2015

The new date pipe only supports date objects or numbers but not ISO strings. In ng1 this was valid and made displaying simple JSON from api's to the UI very easy with little conversion process.

Plunker with ng1 behavior date filter ng1 iso

@zoechi

This comment has been minimized.

Contributor

zoechi commented Jan 26, 2016

dup of #6336

@mip1983

This comment has been minimized.

mip1983 commented May 11, 2016

The date pipe isn't liking this date string: "2015-05-11T17:39:39.6135279+01:00",
Even though JS will take it as a date: var myDate = new Date("2015-05-11T17:39:39.6135279+01:00");

@laskoviymishka

This comment has been minimized.

Contributor

laskoviymishka commented May 11, 2016

There is PR for these feature already created #8038, I need to adjust to rc1

@zoechi

This comment has been minimized.

Contributor

zoechi commented Jun 9, 2016

@mneitzke you need to pass a Date not a string

@laskoviymishka

This comment has been minimized.

Contributor

laskoviymishka commented Jun 9, 2016

@mneitzke you have to cast your string to number.

let invalideDate = '1465495545311';
let validDate = 1465495545311;
@laskoviymishka

This comment has been minimized.

Contributor

laskoviymishka commented Jun 9, 2016

@mneitzke understood your concern. Iso string alredy in code base, but still not in NPM.

@awerlang

This comment has been minimized.

Contributor

awerlang commented Jun 9, 2016

@mneitzke new Date('1465495545311') gives Invalid Date. So I wouldn't expect nor want this special case handled in core, considering that you can plugin a pipe for you case.

@mneitzke

This comment has been minimized.

mneitzke commented Jun 9, 2016

Whatever. Sorry for attempting to contribute.

@laskoviymishka

This comment has been minimized.

Contributor

laskoviymishka commented Jun 9, 2016

@mneitzke don't worry, you doing it great!

@laskoviymishka laskoviymishka referenced this issue Jun 9, 2016

Closed

feat(datePipe): numeric string support #9124

4 of 12 tasks complete
@mhevery

This comment has been minimized.

Member

mhevery commented Jul 1, 2016

fixed

@mhevery mhevery closed this Jul 1, 2016

@razvanmitre

This comment has been minimized.

razvanmitre commented Aug 24, 2016

Hello,

On Safari 9.1.2 it still throws this error. I am using angular rc5.
Invalid argument '2016-08-05T04:50:42+0300' for pipe 'DatePipe'

I don't think it matters, but I use the following polyfills for ECMAScript Internationalization API:

      'vendor/intl/dist/Intl.min.js',
      'vendor/intl/locale-data/jsonp/en.js',
      'vendor/intl/locale-data/jsonp/ro.js',
      'vendor/intl/locale-data/jsonp/ro-RO.js',
      'https://cdn.polyfill.io/v2/polyfill.min.js?features=Intl.~locale.en'

Thanks

@awerlang

This comment has been minimized.

Contributor

awerlang commented Aug 24, 2016

'2016-08-05T04:50:42+0300' is incorrect according to ECMA-262
'2016-08-05T04:50:42+03:00' is correct and parses in Safari, notice the : in the timezone offset

Reference: http://www.ecma-international.org/ecma-262/7.0/index.html#sec-date-time-string-format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment