question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Date/time short format display in Safari

See original GitHub issue

Hello all,

Thanks for your great library.

I’m submitting a…


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

When formatting with translocoDate: { dateStyle: 'short', timeStyle: 'short' }, I get different results between Chrome/Firefox/Edge and Safari. In Safari, the time is omitted.

Minimal reproduction of the problem with instructions

I’ve put together a stackblitz project to demonstrate, forked from your excellent example project:

https://stackblitz.com/edit/transloco-example-aiiepr?file=src%2Fapp%2Flocale%2Flocale%2Flocale.component.html

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

I’m currently developing a SPA app and need it to display consistently on Android and iOS.

Environment


Angular version: 9 (@latest)

Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [x] Safari (desktop) version XX
- [x] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: v10.15.3 (locally)
- Platform: (Mac, Windows)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
tsvetan-ganevcommented, Nov 3, 2020

I encountered the same problem even in the latest versions of Safari (14.0). The solution is not to use the shorthand format style notations: 'short', 'medium', 'long' and instead explicitly set hour, minute, second, day, month etc.

For example, instead of using { dateStyle: 'short' } you should declare it as:

date | translocoDate: { hour: 'numeric', minute: 'numeric', second: 'numeric' }

If you stick to the full notation you can avoid including a polyfill.

2reactions
KrisHaneycommented, Jun 1, 2020

@itayod Okay, I’ll see what I can do. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change how dates, times, and more display on Mac
Change how dates, times, and more display on Mac · On your Mac, choose Apple menu > System Settings, click General in the...
Read more >
Safari JS cannot parse YYYY-MM-DD date format?
With Safari 4/5 (on Mac OSX) the Javascript fails to parse dates of the format YYYY-MM-DD , returning NaN instead of the expected...
Read more >
Javascript and Safari Date format - Burningthumb Studios
Update: Apple replied to my bug report about Javascript and the Safari Date format saying that this issue is fixed in the latest...
Read more >
Intl.DateTimeFormat.prototype.formatRange() - JavaScript | MDN
formatRange() formats a date range in the most concise way based on the locale and ... JavaScript Demo: Intl.DateTimeFormat.prototype. ... Safari on iOS14.5....
Read more >
How to Change the Date Format on a Mac - wikiHow
1. Click the Apple icon. It's the Apple logo at the top left corner of the menu bar. 2. Click System Preferences. 3....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found