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

Change message timestamp format #2162

Closed
Haarolean opened this issue Jun 14, 2022 Discussed in #2159 · 13 comments · Fixed by #3113 or #3119
Closed

Change message timestamp format #2162

Haarolean opened this issue Jun 14, 2022 Discussed in #2159 · 13 comments · Fixed by #3113 or #3119
Assignees
Labels
scope/backend scope/frontend status/accepted An issue which has passed triage and has been accepted type/enhancement En enhancement to an already existing feature
Milestone

Comments

@Haarolean
Copy link
Contributor

Haarolean commented Jun 14, 2022

US locale: mm/dd/yyyy
any other locale: dd-mm-yyyy

image

@Haarolean Haarolean added good first issue Up for grabs scope/frontend status/accepted An issue which has passed triage and has been accepted type/chore Boring stuff, could be refactoring or tech debt labels Jun 14, 2022
@github-actions github-actions bot added the status/triage Issues pending maintainers triage label Jun 14, 2022
@Haarolean Haarolean removed the status/triage Issues pending maintainers triage label Jun 14, 2022
@hyzyla
Copy link

hyzyla commented Jul 8, 2022

I will try to fix that issue ✋

@Haarolean
Copy link
Contributor Author

I will try to fix that issue ✋

hey, thanks for the interest, I've assigned the issue to you

@germanosin
Copy link
Contributor

I think this should be formated locale-based. You could use Date.toLocaleDateString(). @workshur any suggestions?

@Haarolean
Copy link
Contributor Author

I think this should be formated locale-based. You could use Date.toLocaleDateString(). @workshur any suggestions?

that's the next step (#2163). At this point it'd be nice to see dd.MM

@germanosin
Copy link
Contributor

I think we could use localestring for now and then switch to configurable version

@Haarolean
Copy link
Contributor Author

@hyzyla as far as I remember, the timestamp is being formatted on frontend. Can you format it with taking user browser's preferences into consideration?

@Haarolean Haarolean added type/enhancement En enhancement to an already existing feature and removed type/chore Boring stuff, could be refactoring or tech debt labels Jul 8, 2022
@hyzyla
Copy link

hyzyla commented Jul 8, 2022

@hyzyla as far as I remember, the timestamp is being formatted on frontend. Can you format it with taking user browser's preferences into consideration?

Yes, sure

@hyzyla hyzyla mentioned this issue Jul 8, 2022
13 tasks
@hyzyla
Copy link

hyzyla commented Jul 8, 2022

So, after some investigation, I found that formatting to user locale is challenging, because dayjs doesn't support autodetecting locale. For that reason, I decided to just change locale to DD.MM.YYYY.

Let me know if you think that snippet is OK to use for detecting locale

@Haarolean
Copy link
Contributor Author

So, after some investigation, I found that formatting to user locale is challenging, because dayjs doesn't support autodetecting locale. For that reason, I decided to just change locale to DD.MM.YYYY.

Let me know if you think that snippet is OK to use for detecting locale

@provectus/kafka-frontend need opinions

@Haarolean Haarolean self-assigned this Jul 18, 2022
@workshur
Copy link
Member

I would suggest getting rid of dayjs. We only use it in two places. So, let's create an helper function to parse the server date and convert it into a localized format.

try {
  date = new Date('2022-06-06T12:44:42.118Z');
  date.toLocaleString();
} catch ....

@hyzyla
Copy link

hyzyla commented Jul 18, 2022

I would suggest getting rid of dayjs. We only use it in two places. So, let's create an helper function to parse the server date and convert it into a localized format.

try {

  date = new Date('2022-06-06T12:44:42.118Z');

  date.toLocaleString();

} catch ....

Problem with toLocaleString is that function isn't not consistent within different browsers [1]. For example, I have "uk" locale, but Firefox decide to format in en-US, while Chrome format in some weird format 18/06/2022

  1. https://stackoverflow.com/a/66578542

@workshur
Copy link
Member

From my point of view, there is no right solution. Let's wait until BE for the custom locale is ready. Let the user decide which format is more convenient for him

@Haarolean Haarolean removed their assignment Nov 9, 2022
@Haarolean
Copy link
Contributor Author

@hyzyla actually are you sure your browser locales are 'uk'? It seems like both are us

@Haarolean Haarolean assigned Haarolean and unassigned hyzyla Nov 10, 2022
@Haarolean Haarolean removed the good first issue Up for grabs label Dec 21, 2022
@Haarolean Haarolean added this to the 0.5 milestone Dec 21, 2022
@Mgrdich Mgrdich linked a pull request Dec 22, 2022 that will close this issue
13 tasks
@Haarolean Haarolean changed the title Message timestamp format Change message timestamp format Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope/backend scope/frontend status/accepted An issue which has passed triage and has been accepted type/enhancement En enhancement to an already existing feature
Projects
None yet
5 participants