Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

humanize-duration

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

humanize-duration - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

test/test-korean.js

62

humanize-duration.js

@@ -10,26 +10,5 @@ /*

;(function(global, undefined) {
;(function(global) {
// Start by defining the units and how many ms is in each.
var UNITS = [
{ name: "year", milliseconds: 31557600000 },
{ name: "month", milliseconds: 2629800000 },
{ name: "week", milliseconds: 604800000 },
{ name: "day", milliseconds: 86400000 },
{ name: "hour", milliseconds: 3600000 },
{ name: "minute", milliseconds: 60000 },
{ name: "second", milliseconds: 1000 },
{ name: "millisecond", milliseconds: 1 }
];
// A utility function for creating the strings.
// render(1, "minute") == "1 minute"
// render(12, "hours") == "12 hours"
// render(2, "hour", "es") == "2 horas"
var render = function(count, word, language) {
var dictionary = humanizeDuration.languages[language || humanizeDuration.language];
return count + " " + dictionary[word](count);
};
// The moment (ha) you've all been waiting for: the main function.
// The main function.
var humanizeDuration = function(ms, language) {

@@ -75,4 +54,25 @@

// Start by defining the units and how many ms is in each.
var UNITS = [
{ name: "year", milliseconds: 31557600000 },
{ name: "month", milliseconds: 2629800000 },
{ name: "week", milliseconds: 604800000 },
{ name: "day", milliseconds: 86400000 },
{ name: "hour", milliseconds: 3600000 },
{ name: "minute", milliseconds: 60000 },
{ name: "second", milliseconds: 1000 },
{ name: "millisecond", milliseconds: 1 }
];
// A utility function for creating the strings.
// render(1, "minute") == "1 minute"
// render(12, "hour") == "12 hours"
// render(2, "hour", "es") == "2 horas"
var render = function(count, word, language) {
var dictionary = humanizeDuration.LANGUAGES[language || humanizeDuration.language];
return count + " " + dictionary[word](count);
};
// What are the languages?
humanizeDuration.languages = {
humanizeDuration.LANGUAGES = {
en: {

@@ -127,4 +127,16 @@ year: function(c) { return "year" + ((c !== 1) ? "s" : ""); },

millisecond: function(c) { return "milesegundo" + ((c !== 1) ? "s" : ""); }
},
ko: {
year: function(c) { return "년"; },
month: function(c) { return "개월"; },
week: function(c) { return "주일"; },
day: function(c) { return "일"; },
hour: function(c) { return "시간"; },
minute: function(c) { return "분"; },
second: function(c) { return "초"; },
millisecond: function(c) { return "밀리 초"; }
}
}
};
// What's the default language?
humanizeDuration.language = "en";

@@ -131,0 +143,0 @@

{
"name": "humanize-duration",
"author": "Evan Hahn",
"version": "0.3.0",
"version": "0.4.0",
"description": "Convert millisecond durations to English (or a few other languages).",

@@ -6,0 +6,0 @@ "main": "humanize-duration.js",

@@ -10,2 +10,3 @@ Humanize Duration

humanizeDuration(97320000); // "1 day, 3 hours, 2 minutes"
humanizeDuration(3000, "es"); // "3 segundos"

@@ -15,2 +16,3 @@

humanizeDuration(3000); // "3 secondes"
humanizeDuration(5000, "ko"); // "5 초"

@@ -29,3 +31,3 @@ In the browser:

Currently supported languages:
Supported languages:

@@ -37,3 +39,6 @@ * English (en)

* Portuguese (pt)
* Korean (ko)
Lovingly made by [Evan Hahn](http://evanhahn.com/) with language support by [Martin Prins](https://github.com/magarcia). Enjoy!
Lovingly made by [Evan Hahn](http://evanhahn.com/) with language support by [Martin Prins](https://github.com/magarcia). Thanks to [Filipi Siqueira](https://github.com/filipi777) for Portuguese support.
Enjoy!

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc