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.

Implement library to format time/dates for international users

See original GitHub issue

If you haven’t already, check out our contributing guidelines for onboarding!


Action Performed:

  1. Sign-in to e.cash desktop app or at https://expensify.cash
  2. Send a message to a contact
  3. The date and time on the message will be based on your current location and in US formatting (i.e., Perth Australia in the below example) image

Expected Result:

  • The time format and date format should fit the language and location of users all over the world.
  • We want to create a definition for the date format 12/31/2020 for the US versus 31/12/2020 for the UK (for example).
  • And create a definition for Friday, June 24 in the US, versus Freitag, 24. Juni in Germany (for example).
  • The placement of the date and time stamp on the apps does not need to change - it just needs to be applicable to the location and language of the user.

As part of that, we need to implement a library to format dates.

The moment library handles most of this and we already have a DateUtils.js library. There’s 2 exposed methods right now:

  1. timestampToRelative: we can replace this with moment’s fromNow method, it works practically the same as ours, but is locale aware.
  2. timestampToDateTime: we can replace most of this method with moment’s calendar method that is locale aware. We can tweak the output to match exactly what we have by setting the calendar config
  3. Add locale as the first param to timestampToRelative() and timestampToDateTime()

Any new method we want to expose, will be added there, always taking into consideration using .locale() to set the locale.

Actual Result:

  • At this time, the date format and language is based on US/English

Workaround:

  • Continue using Expensify with the already provided date format.

Platform:

Where is this issue occurring?

Web - yes iOS - yes Android - yes Desktop App - yes Mobile Web - yes

Version Number: 1.0.2-11 (1.0.2-11) Logs: https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos: Any additional supporting documentation

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (19 by maintainers)

github_iconTop GitHub Comments

2reactions
npsedhaincommented, Mar 19, 2021

Hi @iwiznia , based on our conversation, I have updated my proposal -

As stated the first param for both the functions will be the locale both of them can easily set the locale using moment’s locale('<locale>') method.

I believe we have come to the consensus that we need the calendar() method but to lay it out simply we could stick to the default configuration if it works for us for now.

Since we don’t want to populate our bundle by including all the locales, we can simply import the ones we feel will be used and that can work as a foundation towards adding more locales into our application.

Let me know if there is anything else.

Regards, Anup.

1reaction
mallenexpensifycommented, Jul 28, 2021

Closing this, looks like it was paid in Upwork months ago, reopen with comment if needed https://www.upwork.com/ab/c/8577561/contracts/26617789/#milestones%2F20210629%2F20210728

cc @Christinadobrzyn

Read more comments on GitHub >

github_iconTop Results From Across the Web

Implement library to format time/dates for international users
As part of that, we need to implement a library to format dates. The moment library handles most of this and we already...
Read more >
Globalize your date/time/number formats - Windows apps
Design your app to be global-ready by appropriately formatting dates, times, numbers, phone numbers, and currencies.
Read more >
timeDate: Rmetrics - Chronological and Calendar Objects
NOTE: Rmetrics has implemented an automated date/time format identifier for many common date/time formats which tries to automatically recognise ...
Read more >
Turning on international time and date formatting | Trello
Date formatting is changed per-language. For instance, English (US) and Français (Canada) will see a MM/DD/YYYY format.
Read more >
Time and Dates (astropy.time) — Astropy v5.2
The usual way to use astropy.time is to create a Time object by supplying one or more input time values as well as...
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