timeago icon indicating copy to clipboard operation
timeago copied to clipboard

Add `languages::english::EnglishAbbreviated`

Open 9999years opened this issue 5 months ago • 4 comments

This adds a new EnglishAbbreviated Language which takes advantage of the additional Language methods introduced in https://github.com/vi/timeago/pull/36 in order to produce more compact output.

I'm not sure this feature is appropriate for this library (none of the other Languages encode stylistic opinions like this), but I wanted to demonstrate the usage of the features.

9999years avatar Aug 28 '25 21:08 9999years

Maybe this mode should also be documented in the README.md?

vi avatar Aug 29 '25 00:08 vi

TBH I'm not sure if this belongs in the library (I can imagine people wanting week to be w and not wk, for example), I mostly wrote it as an example. But if you want me to polish it for merge, I'm happy to do that!

9999years avatar Aug 29 '25 19:08 9999years

The library's development is mostly driven by external contributions. If you need that function in your app and want to depend on timeago, it can be added.

There is already super-short format in format_5chars, so it may make sense to have moderately abbreviated format as well.

Question whether to do it as a pseudo-language or invent some other API is open. Maybe for the reasons of pragmatism/simplicity abbreviated forms can be kept as pseudo-languages when their number is small (e.g. for in this pull request, it is English-only). If somebody else contributes more abbreviated languages, we can introduce an API change (and keep EnglishAbbreviated as a deprecated alias for English with additional abbrev parameter set).

vi avatar Aug 29 '25 23:08 vi

Note that you may want to add something to from_isolang in mod.rs to make the abbreviated form triggerable. Or at least make it accessible in main.rs CLI tool.

vi avatar Aug 29 '25 23:08 vi