ocpsoft / prettytime

Social Style Date and Time Formatting for Java
http://ocpsoft.org/prettytime/
Apache License 2.0
1.29k stars 252 forks source link

Fix for #227: Wrong grammatical case in german locale when formatting… #229

Closed obecker closed 2 years ago

obecker commented 2 years ago

… a list of durations

Fix for the logic that adjusts the german grammatical case for some units in the decorate and decorateUnrounded methods. The new logic replaces all occurrences of words that need to be adjusted in the translated time string, the old logic did this only for single durations.

This should also fix issue #220, because the new logic simply replaces plural words and doesn't check if the duration is a plural duration.

Contains also a minor improvement in SimpleTimeFormat.isPlural() that prevents computing the same number twice.

lincolnthree commented 2 years ago

Hey @obecker , this looks great! Thanks for the PR.

I think your refactoring in SimpleTimeUnit also looks good. Good catch.

Also, I believe you're correct that we should likely be using the Calendar for all unit tests (At which point it should be refactored into a shared class). I know that would be a BIG PR, but... if you're up for it...

Also, if you do that, or other PRs, could you please use the Eclipse code formatting preferences provided at the root of this project? It would help keep things clean and standard.

Much appreciated!

lincolnthree commented 2 years ago

Sorry, code format file is here: https://github.com/ocpsoft/common/blob/master/ocpsoft-eclipse-code-format.xml

lincolnthree commented 2 years ago

Merged.

obecker commented 2 years ago

Thanks for merging and publishing a new release. Instead of asking everyone to follow the code formatting rules you may consider using a maven plugin that will enforce this. See https://github.com/ocpsoft/prettytime/pull/230