Skip to content

modified date format #2341

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

Merged
merged 4 commits into from
Jan 29, 2019
Merged

Conversation

vanshikaarora
Copy link
Contributor

Earler the date wasn't correctly localized Changing format of display date in SimpleDateFormat function brings it to the format as mentioned

Fixes #2336 Image details: date not correctly localized in Japanese

What changes did you make and why?
Modified media detail fragment

@codecov-io
Copy link

Codecov Report

Merging #2341 into master will not change coverage.
The diff coverage is 0%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #2341   +/-   ##
======================================
  Coverage    5.94%   5.94%           
======================================
  Files         237     237           
  Lines       11348   11348           
  Branches     1022    1022           
======================================
  Hits          675     675           
  Misses      10620   10620           
  Partials       53      53
Impacted Files Coverage Δ
...fr/free/nrw/commons/media/MediaDetailFragment.java 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ddc83f1...7d20bb1. Read the comment docs.

@maskaravivek
Copy link
Member

Found this in Wikipedia's code base:

private static String getDateStringWithSkeletonPattern(@NonNull Date date, @NonNull String pattern) {
        return new SimpleDateFormat(android.text.format.DateFormat.getBestDateTimePattern(Locale.getDefault(), pattern), Locale.getDefault()).format(date);
    }

calling it like:

getDateStringWithSkeletonPattern(date, "dd MMM yyyy")

@vanshikaarora
Copy link
Contributor Author

Found this in Wikipedia's code base:

private static String getDateStringWithSkeletonPattern(@NonNull Date date, @NonNull String pattern) {
        return new SimpleDateFormat(android.text.format.DateFormat.getBestDateTimePattern(Locale.getDefault(), pattern), Locale.getDefault()).format(date);
    }

calling it like:

getDateStringWithSkeletonPattern(date, "dd MMM yyyy")

getBestDateTimePattern

@maskaravivek does this getBestDateTimePattern supplies approiate ormat for different languages?

@maskaravivek
Copy link
Member

Looks like! You will have to play around a bit. :)

@vanshikaarora
Copy link
Contributor Author

@maskaravivek I have added the function in DateUtil.
Kindly review and share your feedback :)

@nicolas-raoul
Copy link
Member

Could you please post a screenshot in Japanese? An important difference of Japanese is that it places the year first.
Thanks! :-)

@vanshikaarora
Copy link
Contributor Author

@nicolas-raoul Can you suggest me any other such language. Actually my phone doesn't supports japanese

@nicolas-raoul
Copy link
Member

I suggest Chinese or Persian (Iran).
The best would be to try a language of each color zone:
https://en.wikipedia.org/wiki/Date_format_by_country#Usage_map

@vanshikaarora
Copy link
Contributor Author

OK I'll check that out 👍

@vanshikaarora
Copy link
Contributor Author

I suggest Chinese or Persian (Iran).
The best would be to try a language of each color zone:
https://en.wikipedia.org/wiki/Date_format_by_country#Usage_map

@nicolas-raoul I have tried for each color zone

For Chinese
whatsapp image 2019-01-29 at 3 55 23 pm 4

For Hindi
whatsapp image 2019-01-29 at 3 55 23 pm 3

For Philippines
whatsapp image 2019-01-29 at 3 55 23 pm 2

For canada
whatsapp image 2019-01-29 at 3 55 23 pm 1

For German
whatsapp image 2019-01-29 at 3 55 23 pm

@nicolas-raoul
Copy link
Member

The screenshots look perfect :-)

@maskaravivek maskaravivek merged commit f38feda into commons-app:master Jan 29, 2019
@vanshikaarora
Copy link
Contributor Author

The screenshots look perfect :-)

Good to see this :)

@vanshikaarora
Copy link
Contributor Author

Thanks for approving the Pull Request :)

@vanshikaarora vanshikaarora deleted the date_localize branch January 29, 2019 11:09
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

Successfully merging this pull request may close these issues.

4 participants