jsr icon indicating copy to clipboard operation
jsr copied to clipboard

feat(twas): refracto to use intl api

Open AugustinMauroy opened this issue 10 months ago • 9 comments

Use intl api instead of dep

AugustinMauroy avatar Feb 22 '25 14:02 AugustinMauroy

has been extensively tested

That's not right my lib have more test case and 100% test coverage. I'm working on CI that test the package on deno and bun

On the other hand, the library you suggest you just created it recently, exactly one hour ago, which implies that it has not yet been sufficiently evaluated in different scenarios. Also, since Deno is compatible with NPM, it is not strictly necessary to migrate to a library published in JSR unless there is a compelling reason, such as a deprecation or a significant advantage.

I agree with you on much of it. But don't forget that SJR's source code represents the entire project. And if it's too dependent on NPM, it's not very serious: a registry that needs another registry to function is “the snake that dies on its own tail”.

AugustinMauroy avatar Feb 22 '25 15:02 AugustinMauroy

After reviewing the original package alongside your proposed implementation, I've noticed that the way time interval and time difference calculations are handled is very similar to the code found in this repository (the current package used), which is licensed under MIT. The logic and structure are nearly identical, and they even share the same naming conventions and package name—aside from a few added configuration and test files.

Could you please confirm whether both codebases have been carefully compared for any discrepancies, and that the proper MIT license attribution is maintained in both cases? This similarity reinforces my earlier point that the changes may not provide a significant improvement or benefit overall compared with current package.

EGAMAGZ avatar Feb 22 '25 17:02 EGAMAGZ

Could you please confirm whether both codebases have been carefully compared for any discrepancies, and that the proper MIT license attribution is maintained in both cases? This similarity reinforces my earlier point that the changes may not provide a significant improvement or benefit overall compared with current package.

That just a rewrite in typescript and "modernize". According to my research, this should not violate the MIT license.

AugustinMauroy avatar Feb 22 '25 18:02 AugustinMauroy

I would actually be in favour of not using a dependency, and instead use https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat (or Duration from temporal)

crowlKats avatar Mar 11 '25 01:03 crowlKats

I would actually be in favour of not using a dependency, and instead use https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat (or Duration from temporal)

I'll try to see how to use Intl

AugustinMauroy avatar Mar 11 '25 10:03 AugustinMauroy

Screenshot 2025-03-26 at 15 44 50 Screenshot 2025-03-26 at 15 45 04

just looked at this live, and seems it is kinda too detailed. @kt3k could you advise here?

crowlKats avatar Mar 26 '25 14:03 crowlKats

I would only show the largest unit like:

if (duration.years >= 1) {
  return formatter.format({ years: duration.years }) + " ago";
} else if (duration.months >= 1) {
  return formatter.format({ months: duration.months }) + " ago";
} else if (duration.days => 1) {
  return formatter.format({ days: duration.days }) + " ago";
} else if (duration.hours >= 1) {
  return formatter.format({ hours: duration.hours }) + " ago";
} ...

FYI I do something like this in my blog implementation (using Temporal.Duration object) https://github.com/kt3k/times-kt3k/blob/8353c9c4f15e23b090b7a467f098348c968be7cd/components/post.tsx#L60-L72

kt3k avatar Mar 27 '25 02:03 kt3k

hummm interesting !

AugustinMauroy avatar Mar 28 '25 09:03 AugustinMauroy

Also, take a look at https://github.com/denoland/saaskit/blob/ba68c58ead38e97fe6c469e4ca73a464703568a5/utils/display.ts#L31-L54

iuioiua avatar Apr 22 '25 00:04 iuioiua