Skip to content
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

Dates to use browser or standard format #2185

Closed
ivnnv opened this issue Nov 3, 2024 · 8 comments
Closed

Dates to use browser or standard format #2185

ivnnv opened this issue Nov 3, 2024 · 8 comments

Comments

@ivnnv
Copy link

ivnnv commented Nov 3, 2024

Is your feature request related to a problem? Please describe.
Both a feature request and a problem, deploy dates are shown in american format, which is extremely confusing for non-american people as something like
Screenshot 2024-11-03 at 19 47 53
will read as "eleven of march of 2024", when its actually "three of november of 2024"

Describe the solution you'd like
This and other dates to localize using the browser configuration or just use non-opinionated standard YYYY/MM/DD

UPDATE: In case you were wondering, my locale is correctly set, and it correctly transforms dates coming as YYYY/MM/DD:
Screenshot 2024-11-03 at 20 02 17

I had a quick look at the frontend and maybe moment is not doing its job well here:
https://github.com/caprover/caprover-frontend/blob/master/src/containers/global/Timestamp.tsx#L12

@githubsaturn
Copy link
Collaborator

What version you're on?

@ivnnv
Copy link
Author

ivnnv commented Nov 3, 2024

Hi @githubsaturn, thanks for the prompt response, Ive updated the main comment with extra context:

Im in the latest version:

Current Version: 1.13.1

Latest Stable Version: 1.13.1

Your CapRover is the latest version.

@githubsaturn
Copy link
Collaborator

Yes, this was supposed to fix that :/
caprover/caprover-frontend@d4848eb

@githubsaturn
Copy link
Collaborator

To provide more context, we don't want to use the browser built-in version as it's just too long. That's why we're using moment.

@ivnnv
Copy link
Author

ivnnv commented Nov 3, 2024

This is interesting, my system (macOS) and browser language are set to english as primary, but my OS date format is indeed set as DD/MM/YYYY (Im spanish so thats more natural for me), and that is what it seems the browser internally uses on the Date.toLocaleString() internal implementation, while moment shortcuts only rely on the language

Screenshot 2024-11-03 at 23 28 26

Is it really that long toLocaleString()? it seems it only adds the seconds (03/11/2024, 23:25:07), which could be removed.
Screenshot 2024-11-03 at 23 38 59

@githubsaturn
Copy link
Collaborator

Yea, perhaps something like this could work:

const date = new Date();
const options = {
  year: 'numeric',
  month: 'numeric',
  day: 'numeric',
  hour: '2-digit',
  minute: '2-digit'
};

const formattedDate = date.toLocaleString('default', options);
console.log(formattedDate);

@ivnnv
Copy link
Author

ivnnv commented Nov 4, 2024

@githubsaturn
Copy link
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants