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

Wrong human text #250

Open
antonio-fr opened this issue Feb 11, 2023 · 5 comments
Open

Wrong human text #250

antonio-fr opened this issue Feb 11, 2023 · 5 comments

Comments

@antonio-fr
Copy link

I'm supposing this is the code that writes dates on Github web front.

1 year ago, it writes "2 years ago"
image

@turbo
Copy link
Member

turbo commented Feb 14, 2023

Same issue on https://github.com/grayjoking/backhand (flagged up by user):

image

@stapelberg
Copy link

Here’s a test case that illustrates the issue:

--- a/test/relative-time.js
+++ b/test/relative-time.js
@@ -2411,18 +2411,18 @@ suite('relative-time', function () {
         expected: 'in 3 years',
       },
       {
-        reference: '2022-12-31T12:00:00.000Z',
-        datetime: '2024-03-01T12:00:00.000Z',
-        tense: 'future',
-        format: 'micro',
-        expected: '3y',
+        reference: '2023-02-18T19:00:00.000Z',
+        datetime: '2021-02-02T20:49:31.000Z',
+        tense: 'past',
+        format: 'auto',
+        expected: '2 years ago',
       },
       {
-        reference: '2021-04-24T12:00:00.000Z',
-        datetime: '2023-02-01T12:00:00.000Z',
-        tense: 'future',
-        format: 'micro',
-        expected: '2y',
+        reference: '2023-02-18T19:00:00.000Z',
+        datetime: '2021-01-23T09:28:06.000Z',
+        tense: 'past',
+        format: 'auto',
+        expected: '2 years ago',
       },
     ])

Output:

test/relative-time.js:

 ❌ relative-time > legacy formats > <relative-time datetime="2021-02-02T20:49:31.000Z" tense="past" format="auto"  > => 2 years ago
      AssertionError: expected '3 years ago' to equal '2 years ago'
      + expected - actual
      
      -3 years ago
      +2 years ago

Might be related to #249? cc @keithamus

@keithamus
Copy link
Member

I have a refactor PR that’ll be ready soon which will resolve these without regressing the other cases we’ve run into.

@Wulfheart
Copy link

Wulfheart commented Aug 29, 2023

@keithamus currently I am trying to dive into the code. Could you please point me to the PR with the refactoring?

@keithamus
Copy link
Member

I did some work on trying to create a polyfill for Temporal Durations so we could move to those but the work stalled due to the complexity of the Temporal APIs. I don't have an active branch or PR so the current code is the latest iteration.

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

5 participants