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

Rounding rules are not ignored if locale is de #218

Open
caad1229 opened this issue Jun 4, 2021 · 3 comments
Open

Rounding rules are not ignored if locale is de #218

caad1229 opened this issue Jun 4, 2021 · 3 comments

Comments

@caad1229
Copy link

caad1229 commented Jun 4, 2021

Hi,
Calling the formatUnrounded method will ignore the rounding when I use the German format.

Therefore, rounding is effective and the expected value cannot be obtained.
Below is a test snippet.

    @Test
    fun diffTime_de() {
        val from = Date(2021, 5, 1, 23, 45, 0)
        // just ago 1min
        val to1 = Date(2021, 5, 1, 23, 44, 0)
        // ago 1min 59sec
        val to2 = Date(2021, 5, 1, 23, 43, 1)

        // set locale to de
        val diffTime = PrettyTime(Locale.GERMAN).setReference(from)

        // > success
        assertEquals("vor 1 Minute", diffTime.format(to1))
        // > success
        assertEquals("vor 1 Minute", diffTime.formatUnrounded(to1))

        // > success
        assertEquals("vor 2 Minuten", diffTime.format(to2))
        // > failed : Actual "vor 1 Minuten"
        assertEquals("vor 1 Minute", diffTime.formatUnrounded(to2))
    }

Best regards

@lincolnthree
Copy link
Member

Hey @caad1229,

Thanks so much for the issue report. This is an interesting one. Since you've already dug around in the internals a bit, any chance you feel like sending a PR for this? I'd be happy to get it merged if you get this fixed :)

Based on the fact that this is calling a super class, I'm wondering if this potentially an issue with other languages as well? Or do you feel this is only an issue with German?

Cheers!
~Lincoln

@ShareASmile
Copy link
Contributor

ShareASmile commented Sep 4, 2023

Hi, @lincolnthree would this issue be taken care of by yourself ! It is there for quite a while.

@lincolnthree
Copy link
Member

@ShareASmile As this only impacts very specific usage of the German translation, it is not very high priority. PRs welcome. 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

3 participants