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

Use locale-dependent date display format #33

Open
5 tasks done
Aga-C opened this issue Jan 6, 2024 · 1 comment
Open
5 tasks done

Use locale-dependent date display format #33

Aga-C opened this issue Jan 6, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Aga-C
Copy link
Member

Aga-C commented Jan 6, 2024

Checklist

  • I made sure that there are no existing issues - open or closed - to which I could contribute my information.
  • I have read the FAQ and my problem isn't listed.
  • I have taken the time to fill in all the required details. I understand that the feature request will be dismissed otherwise.
  • This issue contains only one feature request.
  • I have read and understood the contribution guidelines.

Is your feature request related to a problem? Please describe.
Currently, there is only US date format that can't be changed in any way. Different countries have different ways of displaying date.

For example, on the widget there is in English: "Jan 6 2024", but in Polish it shouldn't be "sty 6 2024" but "6 sty 2024".

Describe the solution you'd like
I think the best would be to use the default format from the OS for the region that user's currently in.

Additional context
Places where the date format should be changed:

  • event list widget
  • daily view
  • create/edit event/task view
@Aga-C Aga-C added the enhancement New feature or request label Jan 6, 2024
@PattaFeuFeu
Copy link

PattaFeuFeu commented Jan 7, 2024

This one is very easy to get right with DateTimeFormatter#ofLocalizedDate, but that’s a Java8 java.time class.

I’d like to implement java.time anyway in #37 and then this one here would be almost done.

For testing how that’d look, you can throw the following into a scratch file in Android Studio / IntelliJ:

import java.text.DateFormat
import java.time.LocalDate
import java.time.format.DateTimeFormatter
import java.time.format.FormatStyle

private val dateFormat = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM)

private val date = LocalDate.of(2024, 1, 6)

DateFormat.getAvailableLocales()
    .sortedBy { it.language }
    .map { "${it.language}(${it.country}): ${dateFormat.withLocale(it).format(date)}" }
    .forEach(::println)
...
de(DE): 06.01.2024
...
en(GB): 6 Jan 2024
en(US): Jan 6, 2024
...
pl(PL): 6 sty 2024
pl(PL): 6 sty 2024
pl(): 6 sty 2024
...

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

No branches or pull requests

2 participants