angular: DatePipe does not support timezone abbreviations in Angular 5

I’m submitting a…


[x] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Using a timezone abbreviation such as America/Chicago results in using the local timezone instead.

Expected behavior

Expect DatePipe to accept a timezone abbreviation as referenced in the documentation.

Minimal reproduction of the problem with instructions

http://plnkr.co/edit/luoSIX0gutzIIN7Xoosz?p=preview

See code here. I traced the code from the DatePipe to timezoneToOffset and it appears there is no logic to handle timezone abbreviations. Only offsets.

What is the motivation / use case for changing the behavior?

To be able to use the pipe as described in documentation

timezone to be used for formatting. It understands UTC/GMT and the continental US time zone abbreviations, but for general use, use a time zone offset, for example, '+0430' (4 hours, 30 minutes east of the Greenwich meridian) If not specified, the local system timezone of the end-user’s browser will be used.

Environment


Angular version: 5.0.0


Browser: 

- [X] Chrome (desktop) version 33
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
N/A

Others:
N/A

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 17
  • Comments: 19 (7 by maintainers)

Most upvoted comments

Now that TZ names are no longer supported, what is the intended way to specify a timezone that adheres to daylight savings?

For example having a timezone set to “America/Chicago”, it would be UTC-5 (CDT) or UTC-6 (CST) depending on the date being formatted. How should this be handled?

This seems like a huge step back to me. If the new pipes expect you to know what the offset is for a particular date then you might as well process that on the server (or use moment.js or date-fns.js). I just don’t get the point of having a date pipe that only uses the offset (and then calls it a timezone in the docs!). We do everything in our backend in UTC, then rely on front-end tools like angular to take care of converting that to local times for the user.

@jppellerin good point. A time zone and an utc-offset are not the same! That means actually you would have to calculate the offset for every date you’re displaying.