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

Some languages do not provide time units when formatting a duration #259

Open
lbenedetto opened this issue Jun 15, 2023 · 1 comment
Open

Comments

@lbenedetto
Copy link

lbenedetto commented Jun 15, 2023

Polish (pl), Russian (ru), Ukrainian (uk), and Kazakh (kk) do not provide time units when formatting a duration.

    @Test fun testPL() = testPrettyTimeFails(Locale("pl"))
    @Test fun testRU() = testPrettyTimeFails(Locale("ru"))
    @Test fun testUK() = testPrettyTimeFails(Locale("uk"))
    @Test fun testKK() = testPrettyTimeFails(Locale("kk"))

    private fun testPrettyTimeFails(locale: Locale) {
        val date = Date.from(Instant.now().minus(Duration.ofDays(1)))
        val durationString = PrettyTime(locale).formatDuration(date)
        assertNotEquals("1", durationString)
    }

This is because these four languages override TimeFormat::format with an implementation similar to this:

@Override
public String format(Duration duration)
{
    long quantity = duration.getQuantityRounded(tolerance);
    return String.valueOf(quantity);
}
dessalines added a commit to LemmyNet/jerboa that referenced this issue Jun 19, 2023
A bug in PrettyTime causes four languages to not get any time units when formatted. We can work around this by detecting an invalid prettyDate (rather than hardcoding a list of broken languages) and switching to English formatting instead.

ocpsoft/prettytime#259

Co-authored-by: Dessalines <[email protected]>
@lincolnthree
Copy link
Member

@lbenedetto Hey, thanks for reporting - and @Snow4DV thanks for fixing (for Russian). Hoping you can also work on the others! I am unfortunately not familiar with these languages!

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

2 participants