Humanize Duration

May 20, 2024 · View on GitHub

This friendly fork of @EvanHahn's HumanizeDuration.js uses the shortest non-ambiguous terms for the units of time.

For example, the following abbreviations for English (en) are used:

UnitAbbreviation
Year(s)"y"
Month(s)"mo"
Day(s)"d"
Hour(s)"h"
Minute(s)"m"
Second(s)"s"
Millisecond(s)"ms"

It also replaces the default spacer of " " with "", and the default delimiter of ", " with " ".

So, what was shown as "1 hour, 2 minutes, 3 seconds", this fork shows as "1h 2m 3s".

When possible, the shortest unit of time will get the shortest abbreviation. For example, in English, the word "minute" is abbreviated as "m", and "month" as "mo".

Why create this fork

This fork's parent, EvanHahn/HumanizeDuration.js says "This library is actively maintained but no new features will be added."

Halucinations

ChatGPT and Bard/Gemini were used to provide the abbreviations, so it's possible they halucinated. If you find anything that can be improved, please create an issue, or submit a PR. Thanks.

Supported languages

Humanize Duration supports the following languages:

LanguageTranslationCode
AfrikaansAfrikaansaf
Albanianshqipsq
Amharicአማርኛam
Arabicالعربيةar
Basqueeuskaraeu
Bengaliবাংলাbn
Bulgarianбългарскиbg
Catalancatalàca
Central Kurdishکوردیی ناوەڕاستckb
Chinese, simplified中文 (简体)zh_CN
Chinese, traditional中文 (繁體)zh_TW
Croatianhrvatskihr
Czechčeštinacs
Danishdanskda
DutchNederlandsnl
EnglishEnglishen
EsperantoEsperantoeo
Estonianeesti keelet
Faroeseføroysktfo
Farsi/Persianفارسیfa
Finnishsuomifi
Frenchfrançaisfr
GermanDeutschde
GreekΕλληνικάel
Hebrewעבריתhe
Hindiहिंदीhi
Hungarianmagyarhu
Icelandicíslenskais
IndonesianIndonesiaid
Italianitalianoit
Japanese日本語ja
Kannadaಕನ್ನಡkn
Khmerភាសាខ្មែរkm
Korean한국어ko
KurdishKurdîku
Laoລາວlo
Latvianlatviešulv
Lithuanianlietuviųlt
Macedonianмакедонскиmk
Mongolianмонголmn
MalayMelayums
Marathiमराठीmr
Norwegiannorskno
Polishpolskipl
Portugueseportuguêspt
Romanianromânăro
Russianрусскийru
Serbianсрпскиsr
Slovakslovenčinask
Slovenianslovenščinasl
Spanishespañoles
SwahiliKiswahilisw
Swedishsvenskasv
Tamilதமிழ்ta
Teluguతెలుగుte
Thaiไทยth
TurkishTürkçetr
Ukrainianукраїнськаuk
Urduاردوur
Uzbeko'zbekuz
Uzbek (Cyrillic)Ўзбек (Кирилл)uz_CYR
VietnameseTiếng Việtvi
WelshCymraegcy

More information

For more information on the package this was forked from, visit EvanHahn/HumanizeDuration.js.