ocpsoft / prettytime

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

Prettytime.formatUnrounded giving - with russian string #182

Closed B0pol closed 4 years ago

B0pol commented 4 years ago

You can see the date of the videos at the rigth. The screenshot is from NewPipe, using Prettytime.formatUnrounded(Calendar then) function.

You can reproduce it with by adding this in PrettyTimeI18n_RU_Test.java

@Test
public void testCalculatePreciseDuration2() {
    PrettyTime prettyTime = new PrettyTime();
    prettyTime.clearUnits();
    Minute minutoj = new Minute();
    prettyTime.registerUnit(minutoj, new ResourcesTimeFormat(minutoj));
    Assert.assertEquals("40 minutes ago",prettyTime.formatUnrounded(
      prettyTime.calculatePreciseDuration(new Date(new Date().getTime() - 40 * 60 * 1000 - 40 * 1000))));
}

Output:

org.junit.ComparisonFailure: 
Expected :40 minutes ago
Actual   :-40 минут назад

As you can see, there is that -

lincolnthree commented 4 years ago

Hi, thanks for submitting this issue.

Apologies for the delay in responding. I haven't had a chance to evaluate your test case yet (thanks for attaching a reproduction). I will try to get to it soon, but if you find the root cause before then, pull requests are very welcome!

Thanks and sorry again for the wait, ~Lincoln

sryze commented 4 years ago

Hello, I opened a pull request to fix this issue in NewPipe, please take a look: https://github.com/ocpsoft/prettytime/pull/189

B0pol commented 4 years ago

Fixed by #189