New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

angular-timer

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-timer - npm Package Compare versions

Comparing version 1.3.3 to 1.3.5

bower_components/bootstrap/docs/build/index.js

132

app/js/_timer.js

@@ -15,3 +15,15 @@ var timerModule = angular.module('timer', [])

fallback: '@?',
maxTimeUnit: '='
maxTimeUnit: '=',
seconds: '=?',
minutes: '=?',
hours: '=?',
days: '=?',
months: '=?',
years: '=?',
secondsS: '=?',
minutesS: '=?',
hoursS: '=?',
daysS: '=?',
monthsS: '=?',
yearsS: '=?'
},

@@ -61,3 +73,3 @@ controller: ['$scope', '$element', '$attrs', '$timeout', 'I18nService', '$interpolate', 'progressBarService', function ($scope, $element, $attrs, $timeout, I18nService, $interpolate, progressBarService) {

$scope.timeoutId = null;
$scope.countdown = $scope.countdownattr && parseInt($scope.countdownattr, 10) >= 0 ? parseInt($scope.countdownattr, 10) : undefined;
$scope.countdown = angular.isNumber($scope.countdownattr) && parseInt($scope.countdownattr, 10) >= 0 ? parseInt($scope.countdownattr, 10) : undefined;
$scope.isRunning = false;

@@ -107,7 +119,7 @@

$scope.start = $element[0].start = function () {
$scope.start = function () {
$scope.startTime = $scope.startTimeAttr ? moment($scope.startTimeAttr) : moment();
$scope.endTime = $scope.endTimeAttr ? moment($scope.endTimeAttr) : null;
if (!$scope.countdown) {
$scope.countdown = $scope.countdownattr && parseInt($scope.countdownattr, 10) > 0 ? parseInt($scope.countdownattr, 10) : undefined;
if (!angular.isNumber($scope.countdown)) {
$scope.countdown = angular.isNumber($scope.countdownattr) && parseInt($scope.countdownattr, 10) > 0 ? parseInt($scope.countdownattr, 10) : undefined;
}

@@ -117,5 +129,13 @@ resetTimeout();

$scope.isRunning = true;
$scope.$emit('timer-started', {
timeoutId: $scope.timeoutId,
millis: $scope.millis,
seconds: $scope.seconds,
minutes: $scope.minutes,
hours: $scope.hours,
days: $scope.days
});
};
$scope.resume = $element[0].resume = function () {
$scope.resume = function () {
resetTimeout();

@@ -128,11 +148,26 @@ if ($scope.countdownattr) {

$scope.isRunning = true;
$scope.$emit('timer-started', {
timeoutId: $scope.timeoutId,
millis: $scope.millis,
seconds: $scope.seconds,
minutes: $scope.minutes,
hours: $scope.hours,
days: $scope.days
});
};
$scope.stop = $scope.pause = $element[0].stop = $element[0].pause = function () {
$scope.stop = $scope.pause = function () {
var timeoutId = $scope.timeoutId;
$scope.clear();
$scope.$emit('timer-stopped', {timeoutId: timeoutId, millis: $scope.millis, seconds: $scope.seconds, minutes: $scope.minutes, hours: $scope.hours, days: $scope.days});
$scope.$emit('timer-stopped', {
timeoutId: timeoutId,
millis: $scope.millis,
seconds: $scope.seconds,
minutes: $scope.minutes,
hours: $scope.hours,
days: $scope.days
});
};
$scope.clear = $element[0].clear = function () {
$scope.clear = function () {
// same as stop but without the event being triggered

@@ -145,6 +180,6 @@ $scope.stoppedTime = moment();

$scope.reset = $element[0].reset = function () {
$scope.reset = function () {
$scope.startTime = $scope.startTimeAttr ? moment($scope.startTimeAttr) : moment();
$scope.endTime = $scope.endTimeAttr ? moment($scope.endTimeAttr) : null;
$scope.countdown = $scope.countdownattr && parseInt($scope.countdownattr, 10) > 0 ? parseInt($scope.countdownattr, 10) : undefined;
$scope.countdown = angular.isNumber($scope.countdownattr) && parseInt($scope.countdownattr, 10) > 0 ? parseInt($scope.countdownattr, 10) : undefined;
resetTimeout();

@@ -154,2 +189,10 @@ tick();

$scope.clear();
$scope.$emit('timer-reset', {
timeoutId: timeoutId,
millis: $scope.millis,
seconds: $scope.seconds,
minutes: $scope.minutes,
hours: $scope.hours,
days: $scope.days
});
};

@@ -247,5 +290,4 @@

$scope.addCDSeconds = $element[0].addCDSeconds = function (extraSeconds) {
$scope.addCDSeconds = function (extraSeconds) {
$scope.countdown += extraSeconds;
$scope.$digest();
if (!$scope.isRunning) {

@@ -257,5 +299,3 @@ $scope.start();

$scope.$on('timer-add-cd-seconds', function (e, extraSeconds) {
$timeout(function () {
$scope.addCDSeconds(extraSeconds);
});
$scope.addCDSeconds(extraSeconds);
});

@@ -306,7 +346,16 @@

$scope.timeoutId = setTimeout(function () {
tick();
$scope.$digest();
tick();
// since you choose not to use $timeout, at least preserve angular cycle two way data binding
// by calling $scope.$apply() instead of $scope.$digest()
$scope.$apply();
}, $scope.interval - adjustment);
$scope.$emit('timer-tick', {timeoutId: $scope.timeoutId, millis: $scope.millis});
$scope.$emit('timer-tick', {
timeoutId: $scope.timeoutId,
millis: $scope.millis,
seconds: $scope.seconds,
minutes: $scope.minutes,
hours: $scope.hours,
days: $scope.days
});

@@ -338,3 +387,46 @@ if ($scope.countdown > 0) {

};
}]);
}])
.directive('timerControls', function() {
return {
restrict: 'EA',
scope: true,
controller: ['$scope', function($scope) {
$scope.timerStatus = "reset";
$scope.$on('timer-started', function() {
$scope.timerStatus = "started";
});
$scope.$on('timer-stopped', function() {
$scope.timerStatus = "stopped";
});
$scope.$on('timer-reset', function() {
$scope.timerStatus = "reset";
});
$scope.timerStart = function() {
$scope.$broadcast('timer-start');
};
$scope.timerStop = function() {
$scope.$broadcast('timer-stop');
};
$scope.timerResume = function() {
$scope.$broadcast('timer-resume');
};
$scope.timerToggle = function() {
switch ($scope.timerStatus) {
case "started":
$scope.timerStop();
break;
case "stopped":
$scope.timerResume();
break;
case "reset":
$scope.timerStart();
break;
}
};
$scope.timerAddCDSeconds = function(extraSeconds) {
$scope.$broadcast('timer-add-cd-seconds', extraSeconds);
};
}]
};
});

@@ -341,0 +433,0 @@ /* commonjs package manager support (eg componentjs) */

19

app/js/i18nService.js

@@ -24,4 +24,5 @@ var app = angular.module('timer');

//moment init
moment.locale(this.language); //@TODO maybe to remove, it should be handle by the user's application itself, and not inside the directive
// It should be handle by the user's application itself, and not inside the directive
// moment init
// moment.locale(this.language);

@@ -48,9 +49,9 @@ //human duration init, using it because momentjs does not allow accurate time (

time = {
'millis' : this.timeHumanizer(diffFromAlarm, { units: ["milliseconds"] }),
'seconds' : this.timeHumanizer(diffFromAlarm, { units: ["seconds"] }),
'minutes' : this.timeHumanizer(diffFromAlarm, { units: ["minutes", "seconds"] }) ,
'hours' : this.timeHumanizer(diffFromAlarm, { units: ["hours", "minutes", "seconds"] }) ,
'days' : this.timeHumanizer(diffFromAlarm, { units: ["days", "hours", "minutes", "seconds"] }) ,
'months' : this.timeHumanizer(diffFromAlarm, { units: ["months", "days", "hours", "minutes", "seconds"] }) ,
'years' : this.timeHumanizer(diffFromAlarm, { units: ["years", "months", "days", "hours", "minutes", "seconds"] })
'millis' : this.timeHumanizer(diffFromAlarm, { units: ["ms"] }),
'seconds' : this.timeHumanizer(diffFromAlarm, { units: ["s"] }),
'minutes' : this.timeHumanizer(diffFromAlarm, { units: ["m", "s"] }) ,
'hours' : this.timeHumanizer(diffFromAlarm, { units: ["h", "m", "s"] }) ,
'days' : this.timeHumanizer(diffFromAlarm, { units: ["d", "h", "m", "s"] }) ,
'months' : this.timeHumanizer(diffFromAlarm, { units: ["mo", "d", "h", "m", "s"] }) ,
'years' : this.timeHumanizer(diffFromAlarm, { units: ["y", "mo", "d", "h", "m", "s"] })
};

@@ -57,0 +58,0 @@ }

@@ -5,2 +5,3 @@ {

"Evan Hahn <me@evanhahn.com> (http://evanhahn.com)",
"Óli Tómas Freysson (https://github.com/olitomas)",
"Martin Prins (https://github.com/magarcia)",

@@ -13,5 +14,14 @@ "Filipi Siqueira (https://github.com/filipi777)",

"Giovanni Pellerano (https://github.com/evilaliv3)",
"Rahma Sghaier (https://twitter.com/sghaierrahma)"
"Rahma Sghaier (https://twitter.com/sghaierrahma)",
"Evgenios Kastanias (https://github.com/evgenios)",
"Oleksii Mylotskyi (https://github.com/spalax)",
"Matthew Brandly (https://github.com/brandly)",
"Patrik Simek (https://github.com/patriksimek)",
"Toni Helminen (https://github.com/tonihelminen)",
"Vidmantas Drasutis (https://github.com/drasius2)",
"Manh Tuan (https://github.com/J2TeaM)",
"Leonard Lee (https://github.com/sheeeng)",
"Jesse Jackson (https://github.com/jsejcksn)"
],
"version": "2.8.0",
"version": "3.10.0",
"description": "Convert millisecond durations to English and many other languages.",

@@ -31,3 +41,3 @@ "main": "humanize-duration.js",

],
"license": "WTFPL",
"license": "Unlicense",
"ignore": [

@@ -44,11 +54,11 @@ "**/.*",

},
"_release": "2.8.0",
"_release": "3.10.0",
"_resolution": {
"type": "version",
"tag": "v2.8.0",
"commit": "dcab6eaf100968c008351c70ae3dea9a8a86d929"
"tag": "v3.10.0",
"commit": "18243414dc4ce75d93f6a501f0e88130f2126421"
},
"_source": "git://github.com/EvanHahn/HumanizeDuration.js.git",
"_target": "~2.8.0",
"_source": "https://github.com/EvanHahn/HumanizeDuration.js.git",
"_target": "~3.10.0",
"_originalSource": "humanize-duration"
}

@@ -5,2 +5,3 @@ {

"Evan Hahn <me@evanhahn.com> (http://evanhahn.com)",
"Óli Tómas Freysson (https://github.com/olitomas)",
"Martin Prins (https://github.com/magarcia)",

@@ -13,5 +14,14 @@ "Filipi Siqueira (https://github.com/filipi777)",

"Giovanni Pellerano (https://github.com/evilaliv3)",
"Rahma Sghaier (https://twitter.com/sghaierrahma)"
"Rahma Sghaier (https://twitter.com/sghaierrahma)",
"Evgenios Kastanias (https://github.com/evgenios)",
"Oleksii Mylotskyi (https://github.com/spalax)",
"Matthew Brandly (https://github.com/brandly)",
"Patrik Simek (https://github.com/patriksimek)",
"Toni Helminen (https://github.com/tonihelminen)",
"Vidmantas Drasutis (https://github.com/drasius2)",
"Manh Tuan (https://github.com/J2TeaM)",
"Leonard Lee (https://github.com/sheeeng)",
"Jesse Jackson (https://github.com/jsejcksn)"
],
"version": "2.8.0",
"version": "3.10.0",
"description": "Convert millisecond durations to English and many other languages.",

@@ -31,3 +41,3 @@ "main": "humanize-duration.js",

],
"license": "WTFPL",
"license": "Unlicense",
"ignore": [

@@ -34,0 +44,0 @@ "**/.*",

@@ -6,9 +6,9 @@ How to contribute

1. Fork the repo.
1. Fork the repo on GitHub.
1. Clone the repo.
1. Run `npm install`.
1. Make your changes. Please add tests! If adding a new language, define some tests in *test/definitions*.
1. Make your changes. _Please add tests!_ If adding a new language, define some tests in *test/definitions*.
1. Update `HISTORY.md` with your changes.
1. If adding a new language, add it to the README.
1. Credit yourself in the README and in `package.json`.
1. Credit yourself in the README, in `package.json`, and in `bower.json`.
1. Make sure `npm test` doesn't have any errors.

@@ -15,0 +15,0 @@ 1. Make sure `npm run hint` doesn't give any JSHint errors.

// HumanizeDuration.js - http://git.io/j0HgmQ
(function() {
var UNITS = {
year: 31557600000,
month: 2629800000,
week: 604800000,
day: 86400000,
hour: 3600000,
minute: 60000,
second: 1000,
millisecond: 1
};
;(function () {
var languages = {
ar: {
year: function(c) { return ((c === 1) ? "سنة" : "سنوات"); },
month: function(c) { return ((c === 1) ? "شهر" : "أشهر"); },
week: function(c) { return ((c === 1) ? "أسبوع" : "أسابيع"); },
day: function(c) { return ((c === 1) ? "يوم" : "أيام"); },
hour: function(c) { return ((c === 1) ? "ساعة" : "ساعات"); },
minute: function(c) { return ((c === 1) ? "دقيقة" : "دقائق"); },
second: function(c) { return ((c === 1) ? "ثانية" : "ثواني"); },
millisecond: function(c) { return ((c === 1) ? "جزء من الثانية" : "أجزاء من الثانية"); }
y: function (c) { return c === 1 ? 'سنة' : 'سنوات' },
mo: function (c) { return c === 1 ? 'شهر' : 'أشهر' },
w: function (c) { return c === 1 ? 'أسبوع' : 'أسابيع' },
d: function (c) { return c === 1 ? 'يوم' : 'أيام' },
h: function (c) { return c === 1 ? 'ساعة' : 'ساعات' },
m: function (c) { return c === 1 ? 'دقيقة' : 'دقائق' },
s: function (c) { return c === 1 ? 'ثانية' : 'ثواني' },
ms: function (c) { return c === 1 ? 'جزء من الثانية' : 'أجزاء من الثانية' },
decimal: ','
},
ca: {
year: function(c) { return "any" + ((c !== 1) ? "s" : ""); },
month: function(c) { return "mes" + ((c !== 1) ? "os" : ""); },
week: function(c) { return "setman" + ((c !== 1) ? "es" : "a"); },
day: function(c) { return "di" + ((c !== 1) ? "es" : "a"); },
hour: function(c) { return "hor" + ((c !== 1) ? "es" : "a"); },
minute: function(c) { return "minut" + ((c !== 1) ? "s" : ""); },
second: function(c) { return "segon" + ((c !== 1) ? "s" : ""); },
millisecond: function(c) { return "milisegon" + ((c !== 1) ? "s" : "" ); }
y: function (c) { return 'any' + (c !== 1 ? 's' : '') },
mo: function (c) { return 'mes' + (c !== 1 ? 'os' : '') },
w: function (c) { return 'setman' + (c !== 1 ? 'es' : 'a') },
d: function (c) { return 'di' + (c !== 1 ? 'es' : 'a') },
h: function (c) { return 'hor' + (c !== 1 ? 'es' : 'a') },
m: function (c) { return 'minut' + (c !== 1 ? 's' : '') },
s: function (c) { return 'segon' + (c !== 1 ? 's' : '') },
ms: function (c) { return 'milisegon' + (c !== 1 ? 's' : '') },
decimal: ','
},
cs: {
y: function (c) { return ['rok', 'roku', 'roky', 'let'][getCzechForm(c)] },
mo: function (c) { return ['měsíc', 'měsíce', 'měsíce', 'měsíců'][getCzechForm(c)] },
w: function (c) { return ['týden', 'týdne', 'týdny', 'týdnů'][getCzechForm(c)] },
d: function (c) { return ['den', 'dne', 'dny', 'dní'][getCzechForm(c)] },
h: function (c) { return ['hodina', 'hodiny', 'hodiny', 'hodin'][getCzechForm(c)] },
m: function (c) { return ['minuta', 'minuty', 'minuty', 'minut'][getCzechForm(c)] },
s: function (c) { return ['sekunda', 'sekundy', 'sekundy', 'sekund'][getCzechForm(c)] },
ms: function (c) { return ['milisekunda', 'milisekundy', 'milisekundy', 'milisekund'][getCzechForm(c)] },
decimal: ','
},
da: {
year: "år",
month: function(c) { return "måned" + ((c !== 1) ? "er" : ""); },
week: function(c) { return "uge" + ((c !== 1) ? "r" : ""); },
day: function(c) { return "dag" + ((c !== 1) ? "e" : ""); },
hour: function(c) { return "time" + ((c !== 1) ? "r" : ""); },
minute: function(c) { return "minut" + ((c !== 1) ? "ter" : ""); },
second: function(c) { return "sekund" + ((c !== 1) ? "er" : ""); },
millisecond: function(c) { return "millisekund" + ((c !== 1) ? "er" : ""); }
y: 'år',
mo: function (c) { return 'måned' + (c !== 1 ? 'er' : '') },
w: function (c) { return 'uge' + (c !== 1 ? 'r' : '') },
d: function (c) { return 'dag' + (c !== 1 ? 'e' : '') },
h: function (c) { return 'time' + (c !== 1 ? 'r' : '') },
m: function (c) { return 'minut' + (c !== 1 ? 'ter' : '') },
s: function (c) { return 'sekund' + (c !== 1 ? 'er' : '') },
ms: function (c) { return 'millisekund' + (c !== 1 ? 'er' : '') },
decimal: ','
},
de: {
year: function(c) { return "Jahr" + ((c !== 1) ? "e" : ""); },
month: function(c) { return "Monat" + ((c !== 1) ? "e" : ""); },
week: function(c) { return "Woche" + ((c !== 1) ? "n" : ""); },
day: function(c) { return "Tag" + ((c !== 1) ? "e" : ""); },
hour: function(c) { return "Stunde" + ((c !== 1) ? "n" : ""); },
minute: function(c) { return "Minute" + ((c !== 1) ? "n" : ""); },
second: function(c) { return "Sekunde" + ((c !== 1) ? "n" : ""); },
millisecond: function(c) { return "Millisekunde" + ((c !== 1) ? "n" : ""); }
y: function (c) { return 'Jahr' + (c !== 1 ? 'e' : '') },
mo: function (c) { return 'Monat' + (c !== 1 ? 'e' : '') },
w: function (c) { return 'Woche' + (c !== 1 ? 'n' : '') },
d: function (c) { return 'Tag' + (c !== 1 ? 'e' : '') },
h: function (c) { return 'Stunde' + (c !== 1 ? 'n' : '') },
m: function (c) { return 'Minute' + (c !== 1 ? 'n' : '') },
s: function (c) { return 'Sekunde' + (c !== 1 ? 'n' : '') },
ms: function (c) { return 'Millisekunde' + (c !== 1 ? 'n' : '') },
decimal: ','
},
en: {
year: function(c) { return "year" + ((c !== 1) ? "s" : ""); },
month: function(c) { return "month" + ((c !== 1) ? "s" : ""); },
week: function(c) { return "week" + ((c !== 1) ? "s" : ""); },
day: function(c) { return "day" + ((c !== 1) ? "s" : ""); },
hour: function(c) { return "hour" + ((c !== 1) ? "s" : ""); },
minute: function(c) { return "minute" + ((c !== 1) ? "s" : ""); },
second: function(c) { return "second" + ((c !== 1) ? "s" : ""); },
millisecond: function(c) { return "millisecond" + ((c !== 1) ? "s" : ""); }
y: function (c) { return 'year' + (c !== 1 ? 's' : '') },
mo: function (c) { return 'month' + (c !== 1 ? 's' : '') },
w: function (c) { return 'week' + (c !== 1 ? 's' : '') },
d: function (c) { return 'day' + (c !== 1 ? 's' : '') },
h: function (c) { return 'hour' + (c !== 1 ? 's' : '') },
m: function (c) { return 'minute' + (c !== 1 ? 's' : '') },
s: function (c) { return 'second' + (c !== 1 ? 's' : '') },
ms: function (c) { return 'millisecond' + (c !== 1 ? 's' : '') },
decimal: '.'
},
es: {
year: function(c) { return "año" + ((c !== 1) ? "s" : ""); },
month: function(c) { return "mes" + ((c !== 1) ? "es" : ""); },
week: function(c) { return "semana" + ((c !== 1) ? "s" : ""); },
day: function(c) { return "día" + ((c !== 1) ? "s" : ""); },
hour: function(c) { return "hora" + ((c !== 1) ? "s" : ""); },
minute: function(c) { return "minuto" + ((c !== 1) ? "s" : ""); },
second: function(c) { return "segundo" + ((c !== 1) ? "s" : ""); },
millisecond: function(c) { return "milisegundo" + ((c !== 1) ? "s" : "" ); }
y: function (c) { return 'año' + (c !== 1 ? 's' : '') },
mo: function (c) { return 'mes' + (c !== 1 ? 'es' : '') },
w: function (c) { return 'semana' + (c !== 1 ? 's' : '') },
d: function (c) { return 'día' + (c !== 1 ? 's' : '') },
h: function (c) { return 'hora' + (c !== 1 ? 's' : '') },
m: function (c) { return 'minuto' + (c !== 1 ? 's' : '') },
s: function (c) { return 'segundo' + (c !== 1 ? 's' : '') },
ms: function (c) { return 'milisegundo' + (c !== 1 ? 's' : '') },
decimal: ','
},
fi: {
y: function (c) { return c === 1 ? 'vuosi' : 'vuotta' },
mo: function (c) { return c === 1 ? 'kuukausi' : 'kuukautta' },
w: function (c) { return 'viikko' + (c !== 1 ? 'a' : '') },
d: function (c) { return 'päivä' + (c !== 1 ? 'ä' : '') },
h: function (c) { return 'tunti' + (c !== 1 ? 'a' : '') },
m: function (c) { return 'minuutti' + (c !== 1 ? 'a' : '') },
s: function (c) { return 'sekunti' + (c !== 1 ? 'a' : '') },
ms: function (c) { return 'millisekunti' + (c !== 1 ? 'a' : '') },
decimal: ','
},
fr: {
year: function(c) { return "an" + ((c !== 1) ? "s" : ""); },
month: "mois",
week: function(c) { return "semaine" + ((c !== 1) ? "s" : ""); },
day: function(c) { return "jour" + ((c !== 1) ? "s" : ""); },
hour: function(c) { return "heure" + ((c !== 1) ? "s" : ""); },
minute: function(c) { return "minute" + ((c !== 1) ? "s" : ""); },
second: function(c) { return "seconde" + ((c !== 1) ? "s" : ""); },
millisecond: function(c) { return "milliseconde" + ((c !== 1) ? "s" : ""); }
y: function (c) { return 'an' + (c !== 1 ? 's' : '') },
mo: 'mois',
w: function (c) { return 'semaine' + (c !== 1 ? 's' : '') },
d: function (c) { return 'jour' + (c !== 1 ? 's' : '') },
h: function (c) { return 'heure' + (c !== 1 ? 's' : '') },
m: function (c) { return 'minute' + (c !== 1 ? 's' : '') },
s: function (c) { return 'seconde' + (c !== 1 ? 's' : '') },
ms: function (c) { return 'milliseconde' + (c !== 1 ? 's' : '') },
decimal: ','
},
gr: {
y: function (c) { return c === 1 ? 'χρόνος' : 'χρόνια' },
mo: function (c) { return c === 1 ? 'μήνας' : 'μήνες' },
w: function (c) { return c === 1 ? 'εβδομάδα' : 'εβδομάδες' },
d: function (c) { return c === 1 ? 'μέρα' : 'μέρες' },
h: function (c) { return c === 1 ? 'ώρα' : 'ώρες' },
m: function (c) { return c === 1 ? 'λεπτό' : 'λεπτά' },
s: function (c) { return c === 1 ? 'δευτερόλεπτο' : 'δευτερόλεπτα' },
ms: function (c) { return c === 1 ? 'χιλιοστό του δευτερολέπτου' : 'χιλιοστά του δευτερολέπτου' },
decimal: ','
},
hu: {
year: "év",
month: "hónap",
week: "hét",
day: "nap",
hour: "óra",
minute: "perc",
second: "másodperc",
millisecond: "ezredmásodperc"
y: 'év',
mo: 'hónap',
w: 'hét',
d: 'nap',
h: 'óra',
m: 'perc',
s: 'másodperc',
ms: 'ezredmásodperc',
decimal: ','
},
id: {
y: 'tahun',
mo: 'bulan',
w: 'minggu',
d: 'hari',
h: 'jam',
m: 'menit',
s: 'detik',
ms: 'milidetik',
decimal: '.'
},
is: {
y: 'ár',
mo: function (c) { return 'mánuð' + (c !== 1 ? 'ir' : 'ur') },
w: function (c) { return 'vik' + (c !== 1 ? 'ur' : 'a') },
d: function (c) { return 'dag' + (c !== 1 ? 'ar' : 'ur') },
h: function (c) { return 'klukkutím' + (c !== 1 ? 'ar' : 'i') },
m: function (c) { return 'mínút' + (c !== 1 ? 'ur' : 'a') },
s: function (c) { return 'sekúnd' + (c !== 1 ? 'ur' : 'a') },
ms: function (c) { return 'millisekúnd' + (c !== 1 ? 'ur' : 'a') },
decimal: '.'
},
it: {
year: function(c) { return "ann" + ((c !== 1) ? "i" : "o"); },
month: function(c) { return "mes" + ((c !== 1) ? "i" : "e"); },
week: function(c) { return "settiman" + ((c !== 1) ? "e" : "a"); },
day: function(c) { return "giorn" + ((c !== 1) ? "i" : "o"); },
hour: function(c) { return "or" + ((c !== 1) ? "e" : "a"); },
minute: function(c) { return "minut" + ((c !== 1) ? "i" : "o"); },
second: function(c) { return "second" + ((c !== 1) ? "i" : "o"); },
millisecond: function(c) { return "millisecond" + ((c !== 1) ? "i" : "o" ); }
y: function (c) { return 'ann' + (c !== 1 ? 'i' : 'o') },
mo: function (c) { return 'mes' + (c !== 1 ? 'i' : 'e') },
w: function (c) { return 'settiman' + (c !== 1 ? 'e' : 'a') },
d: function (c) { return 'giorn' + (c !== 1 ? 'i' : 'o') },
h: function (c) { return 'or' + (c !== 1 ? 'e' : 'a') },
m: function (c) { return 'minut' + (c !== 1 ? 'i' : 'o') },
s: function (c) { return 'second' + (c !== 1 ? 'i' : 'o') },
ms: function (c) { return 'millisecond' + (c !== 1 ? 'i' : 'o') },
decimal: ','
},
ja: {
year: "年",
month: "月",
week: "週",
day: "日",
hour: "時間",
minute: "分",
second: "秒",
millisecond: "ミリ秒"
y: '年',
mo: '月',
w: '週',
d: '日',
h: '時間',
m: '分',
s: '秒',
ms: 'ミリ秒',
decimal: '.'
},
ko: {
year: "년",
month: "개월",
week: "주일",
day: "일",
hour: "시간",
minute: "분",
second: "초",
millisecond: "밀리 초"
y: '년',
mo: '개월',
w: '주일',
d: '일',
h: '시간',
m: '분',
s: '초',
ms: '밀리 초',
decimal: '.'
},
lt: {
y: function (c) { return ((c % 10 === 0) || (c % 100 >= 10 && c % 100 <= 20)) ? 'metų' : 'metai' },
mo: function (c) { return ['mėnuo', 'mėnesiai', 'mėnesių'][getLithuanianForm(c)] },
w: function (c) { return ['savaitė', 'savaitės', 'savaičių'][getLithuanianForm(c)] },
d: function (c) { return ['diena', 'dienos', 'dienų'][getLithuanianForm(c)] },
h: function (c) { return ['valanda', 'valandos', 'valandų'][getLithuanianForm(c)] },
m: function (c) { return ['minutė', 'minutės', 'minučių'][getLithuanianForm(c)] },
s: function (c) { return ['sekundė', 'sekundės', 'sekundžių'][getLithuanianForm(c)] },
ms: function (c) { return ['milisekundė', 'milisekundės', 'milisekundžių'][getLithuanianForm(c)] },
decimal: ','
},
ms: {
y: 'tahun',
mo: 'bulan',
w: 'minggu',
d: 'hari',
h: 'jam',
m: 'minit',
s: 'saat',
ms: 'milisaat',
decimal: '.'
},
nl: {
year: "jaar",
month: function(c) { return (c === 1) ? "maand" : "maanden"; },
week: function(c) { return (c === 1) ? "week" : "weken"; },
day: function(c) { return (c === 1) ? "dag" : "dagen"; },
hour: "uur",
minute: function(c) { return (c === 1) ? "minuut" : "minuten"; },
second: function(c) { return (c === 1) ? "seconde" : "seconden"; },
millisecond: function(c) { return (c === 1) ? "milliseconde" : "milliseconden"; }
y: 'jaar',
mo: function (c) { return c === 1 ? 'maand' : 'maanden' },
w: function (c) { return c === 1 ? 'week' : 'weken' },
d: function (c) { return c === 1 ? 'dag' : 'dagen' },
h: 'uur',
m: function (c) { return c === 1 ? 'minuut' : 'minuten' },
s: function (c) { return c === 1 ? 'seconde' : 'seconden' },
ms: function (c) { return c === 1 ? 'milliseconde' : 'milliseconden' },
decimal: ','
},
nob: {
year: "år",
month: function(c) { return "måned" + ((c !== 1) ? "er" : ""); },
week: function(c) { return "uke" + ((c !== 1) ? "r" : ""); },
day: function(c) { return "dag" + ((c !== 1) ? "er" : ""); },
hour: function(c) { return "time" + ((c !== 1) ? "r" : ""); },
minute: function(c) { return "minutt" + ((c !== 1) ? "er" : ""); },
second: function(c) { return "sekund" + ((c !== 1) ? "er" : ""); },
millisecond: function(c) { return "millisekund" + ((c !== 1) ? "er" : ""); }
no: {
y: 'år',
mo: function (c) { return 'måned' + (c !== 1 ? 'er' : '') },
w: function (c) { return 'uke' + (c !== 1 ? 'r' : '') },
d: function (c) { return 'dag' + (c !== 1 ? 'er' : '') },
h: function (c) { return 'time' + (c !== 1 ? 'r' : '') },
m: function (c) { return 'minutt' + (c !== 1 ? 'er' : '') },
s: function (c) { return 'sekund' + (c !== 1 ? 'er' : '') },
ms: function (c) { return 'millisekund' + (c !== 1 ? 'er' : '') },
decimal: ','
},
pl: {
year: function(c) { return ["rok", "roku", "lata", "lat"][getPolishForm(c)]; },
month: function(c) { return ["miesiąc", "miesiąca", "miesiące", "miesięcy"][getPolishForm(c)]; },
week: function(c) { return ["tydzień", "tygodnia", "tygodnie", "tygodni"][getPolishForm(c)]; },
day: function(c) { return ["dzień", "dnia", "dni", "dni"][getPolishForm(c)]; },
hour: function(c) { return ["godzina", "godziny", "godziny", "godzin"][getPolishForm(c)]; },
minute: function(c) { return ["minuta", "minuty", "minuty", "minut"][getPolishForm(c)]; },
second: function(c) { return ["sekunda", "sekundy", "sekundy", "sekund"][getPolishForm(c)]; },
millisecond: function(c) { return ["milisekunda", "milisekundy", "milisekundy", "milisekund"][getPolishForm(c)]; }
y: function (c) { return ['rok', 'roku', 'lata', 'lat'][getPolishForm(c)] },
mo: function (c) { return ['miesiąc', 'miesiąca', 'miesiące', 'miesięcy'][getPolishForm(c)] },
w: function (c) { return ['tydzień', 'tygodnia', 'tygodnie', 'tygodni'][getPolishForm(c)] },
d: function (c) { return ['dzień', 'dnia', 'dni', 'dni'][getPolishForm(c)] },
h: function (c) { return ['godzina', 'godziny', 'godziny', 'godzin'][getPolishForm(c)] },
m: function (c) { return ['minuta', 'minuty', 'minuty', 'minut'][getPolishForm(c)] },
s: function (c) { return ['sekunda', 'sekundy', 'sekundy', 'sekund'][getPolishForm(c)] },
ms: function (c) { return ['milisekunda', 'milisekundy', 'milisekundy', 'milisekund'][getPolishForm(c)] },
decimal: ','
},
pt: {
year: function(c) { return "ano" + ((c !== 1) ? "s" : ""); },
month: function(c) { return (c !== 1) ? "meses" : "mês"; },
week: function(c) { return "semana" + ((c !== 1) ? "s" : ""); },
day: function(c) { return "dia" + ((c !== 1) ? "s" : ""); },
hour: function(c) { return "hora" + ((c !== 1) ? "s" : ""); },
minute: function(c) { return "minuto" + ((c !== 1) ? "s" : ""); },
second: function(c) { return "segundo" + ((c !== 1) ? "s" : ""); },
millisecond: function(c) { return "milissegundo" + ((c !== 1) ? "s" : ""); }
y: function (c) { return 'ano' + (c !== 1 ? 's' : '') },
mo: function (c) { return c !== 1 ? 'meses' : 'mês' },
w: function (c) { return 'semana' + (c !== 1 ? 's' : '') },
d: function (c) { return 'dia' + (c !== 1 ? 's' : '') },
h: function (c) { return 'hora' + (c !== 1 ? 's' : '') },
m: function (c) { return 'minuto' + (c !== 1 ? 's' : '') },
s: function (c) { return 'segundo' + (c !== 1 ? 's' : '') },
ms: function (c) { return 'milissegundo' + (c !== 1 ? 's' : '') },
decimal: ','
},
ru: {
year: function(c) { return ["лет", "год", "года"][getRussianForm(c)]; },
month: function(c) { return ["месяцев", "месяц", "месяца"][getRussianForm(c)]; },
week: function(c) { return ["недель", "неделя", "недели"][getRussianForm(c)]; },
day: function(c) { return ["дней", "день", "дня"][getRussianForm(c)]; },
hour: function(c) { return ["часов", "час", "часа"][getRussianForm(c)]; },
minute: function(c) { return ["минут", "минута", "минуты"][getRussianForm(c)]; },
second: function(c) { return ["секунд", "секунда", "секунды"][getRussianForm(c)]; },
millisecond: function(c) { return ["миллисекунд", "миллисекунда", "миллисекунды"][getRussianForm(c)]; }
y: function (c) { return ['лет', 'год', 'года'][getSlavicForm(c)] },
mo: function (c) { return ['месяцев', 'месяц', 'месяца'][getSlavicForm(c)] },
w: function (c) { return ['недель', 'неделя', 'недели'][getSlavicForm(c)] },
d: function (c) { return ['дней', 'день', 'дня'][getSlavicForm(c)] },
h: function (c) { return ['часов', 'час', 'часа'][getSlavicForm(c)] },
m: function (c) { return ['минут', 'минута', 'минуты'][getSlavicForm(c)] },
s: function (c) { return ['секунд', 'секунда', 'секунды'][getSlavicForm(c)] },
ms: function (c) { return ['миллисекунд', 'миллисекунда', 'миллисекунды'][getSlavicForm(c)] },
decimal: ','
},
uk: {
y: function (c) { return ['років', 'рік', 'роки'][getSlavicForm(c)] },
mo: function (c) { return ['місяців', 'місяць', 'місяці'][getSlavicForm(c)] },
w: function (c) { return ['неділь', 'неділя', 'неділі'][getSlavicForm(c)] },
d: function (c) { return ['днів', 'день', 'дні'][getSlavicForm(c)] },
h: function (c) { return ['годин', 'година', 'години'][getSlavicForm(c)] },
m: function (c) { return ['хвилин', 'хвилина', 'хвилини'][getSlavicForm(c)] },
s: function (c) { return ['секунд', 'секунда', 'секунди'][getSlavicForm(c)] },
ms: function (c) { return ['мілісекунд', 'мілісекунда', 'мілісекунди'][getSlavicForm(c)] },
decimal: ','
},
sv: {
year: "år",
month: function(c) { return "månad" + ((c !== 1) ? "er" : ""); },
week: function(c) { return "veck" + ((c !== 1) ? "or" : "a"); },
day: function(c) { return "dag" + ((c !== 1) ? "ar" : ""); },
hour: function(c) { return "timm" + ((c !== 1) ? "ar" : "e"); },
minute: function(c) { return "minut" + ((c !== 1) ? "er" : ""); },
second: function(c) { return "sekund" + ((c !== 1) ? "er" : ""); },
millisecond: function(c) { return "millisekund" + ((c !== 1) ? "er" : ""); }
y: 'år',
mo: function (c) { return 'månad' + (c !== 1 ? 'er' : '') },
w: function (c) { return 'veck' + (c !== 1 ? 'or' : 'a') },
d: function (c) { return 'dag' + (c !== 1 ? 'ar' : '') },
h: function (c) { return 'timm' + (c !== 1 ? 'ar' : 'e') },
m: function (c) { return 'minut' + (c !== 1 ? 'er' : '') },
s: function (c) { return 'sekund' + (c !== 1 ? 'er' : '') },
ms: function (c) { return 'millisekund' + (c !== 1 ? 'er' : '') },
decimal: ','
},
tr: {
year: "yıl",
month: "ay",
week: "hafta",
day: "gün",
hour: "saat",
minute: "dakika",
second: "saniye",
millisecond: "milisaniye"
y: 'yıl',
mo: 'ay',
w: 'hafta',
d: 'gün',
h: 'saat',
m: 'dakika',
s: 'saniye',
ms: 'milisaniye',
decimal: ','
},
"zh-CN": {
year: "年",
month: "个月",
week: "周",
day: "天",
hour: "小时",
minute: "分钟",
second: "秒",
millisecond: "毫秒"
vi: {
y: 'năm',
mo: 'tháng',
w: 'tuần',
d: 'ngày',
h: 'giờ',
m: 'phút',
s: 'giây',
ms: 'mili giây',
decimal: ','
},
"zh-TW": {
year: "年",
month: "個月",
week: "周",
day: "天",
hour: "小時",
minute: "分鐘",
second: "秒",
millisecond: "毫秒"
zh_CN: {
y: '年',
mo: '个月',
w: '周',
d: '天',
h: '小时',
m: '分钟',
s: '秒',
ms: '毫秒',
decimal: '.'
},
zh_TW: {
y: '年',
mo: '個月',
w: '周',
d: '天',
h: '小時',
m: '分鐘',
s: '秒',
ms: '毫秒',
decimal: '.'
}
};
}
// You can create a humanizer, which returns a function with defaults
// You can create a humanizer, which returns a function with default
// parameters.
function humanizer(passedOptions) {
function humanizer (passedOptions) {
var result = function humanizer (ms, humanizerOptions) {
var options = extend({}, result, humanizerOptions || {})
return doHumanization(ms, options)
}
var result = function humanizer(ms, humanizerOptions) {
var options = extend({}, result, humanizerOptions || {});
return doHumanization(ms, options);
};
return extend(result, {
language: "en",
delimiter: ", ",
spacer: " ",
units: ["year", "month", "week", "day", "hour", "minute", "second"],
language: 'en',
delimiter: ', ',
spacer: ' ',
conjunction: '',
serialComma: true,
units: ['y', 'mo', 'w', 'd', 'h', 'm', 's'],
languages: {},
halfUnit: true,
round: false
}, passedOptions);
round: false,
unitMeasures: {
y: 31557600000,
mo: 2629800000,
w: 604800000,
d: 86400000,
h: 3600000,
m: 60000,
s: 1000,
ms: 1
}
}, passedOptions)
}
// The main function is just a wrapper around a default humanizer.
var defaultHumanizer = humanizer({});
function humanizeDuration() {
return defaultHumanizer.apply(defaultHumanizer, arguments);
}
var humanizeDuration = humanizer({})
// doHumanization does the bulk of the work.
function doHumanization(ms, options) {
function doHumanization (ms, options) {
var i, len, piece
// Make sure we have a positive number.
// Has the nice sideffect of turning Number objects into primitives.
ms = Math.abs(ms);
ms = Math.abs(ms)
if (ms === 0) {
return "0";
}
var dictionary = options.languages[options.language] || languages[options.language];
var dictionary = options.languages[options.language] || languages[options.language]
if (!dictionary) {
throw new Error("No language " + dictionary + ".");
throw new Error('No language ' + dictionary + '.')
}
var result = [];
var pieces = []
// Start at the top and keep removing units, bit by bit.
var unitName, unitMS, unitCount, mightBeHalfUnit;
for (var i = 0, len = options.units.length; i < len; i ++) {
var unitName, unitMS, unitCount
for (i = 0, len = options.units.length; i < len; i++) {
unitName = options.units[i]
unitMS = options.unitMeasures[unitName]
unitName = options.units[i];
if (unitName[unitName.length - 1] === "s") { // strip plurals
unitName = unitName.substring(0, unitName.length - 1);
// What's the number of full units we can fit?
if (i + 1 === len) {
unitCount = ms / unitMS
} else {
unitCount = Math.floor(ms / unitMS)
}
unitMS = UNITS[unitName];
// If it's a half-unit interval, we're done.
if (result.length === 0 && options.halfUnit) {
mightBeHalfUnit = (ms / unitMS) * 2;
if (mightBeHalfUnit === Math.floor(mightBeHalfUnit)) {
return render(mightBeHalfUnit / 2, unitName, dictionary, options.spacer);
}
// Add the string.
pieces.push({
unitCount: unitCount,
unitName: unitName
})
// Remove what we just figured out.
ms -= unitCount * unitMS
}
var firstOccupiedUnitIndex = 0
for (i = 0; i < pieces.length; i++) {
if (pieces[i].unitCount) {
firstOccupiedUnitIndex = i
break
}
}
// What's the number of full units we can fit?
if ((i + 1) === len) {
unitCount = ms / unitMS;
if (options.round) {
unitCount = Math.round(unitCount);
if (options.round) {
var ratioToLargerUnit, previousPiece
for (i = pieces.length - 1; i >= 0; i--) {
piece = pieces[i]
piece.unitCount = Math.round(piece.unitCount)
if (i === 0) { break }
previousPiece = pieces[i - 1]
ratioToLargerUnit = options.unitMeasures[previousPiece.unitName] / options.unitMeasures[piece.unitName]
if ((piece.unitCount % ratioToLargerUnit) === 0 || (options.largest && ((options.largest - 1) < (i - firstOccupiedUnitIndex)))) {
previousPiece.unitCount += piece.unitCount / ratioToLargerUnit
piece.unitCount = 0
}
} else {
unitCount = Math.floor(ms / unitMS);
}
}
// Add the string.
if (unitCount) {
result.push(render(unitCount, unitName, dictionary, options.spacer));
var result = []
for (i = 0, pieces.length; i < len; i++) {
piece = pieces[i]
if (piece.unitCount) {
result.push(render(piece.unitCount, piece.unitName, dictionary, options))
}
// Remove what we just figured out.
ms -= unitCount * unitMS;
if (result.length === options.largest) { break }
}
if (result.length) {
if (!options.conjunction || result.length === 1) {
return result.join(options.delimiter)
} else if (result.length === 2) {
return result.join(options.conjunction)
} else if (result.length > 2) {
return result.slice(0, -1).join(options.delimiter) + (options.serialComma ? ',' : '') + options.conjunction + result.slice(-1)
}
} else {
return render(0, options.units[options.units.length - 1], dictionary, options)
}
}
return result.join(options.delimiter);
function render (count, type, dictionary, options) {
var decimal
if (options.decimal === void 0) {
decimal = dictionary.decimal
} else {
decimal = options.decimal
}
}
var countStr = count.toString().replace('.', decimal)
function render(count, type, dictionary, spacer) {
var dictionaryValue = dictionary[type];
var word;
if (typeof dictionaryValue === "function") {
word = dictionaryValue(count);
var dictionaryValue = dictionary[type]
var word
if (typeof dictionaryValue === 'function') {
word = dictionaryValue(count)
} else {
word = dictionaryValue;
word = dictionaryValue
}
return count + spacer + word;
return countStr + options.spacer + word
}
function extend(destination) {
var source;
for (var i = 1; i < arguments.length; i ++) {
source = arguments[i];
function extend (destination) {
var source
for (var i = 1; i < arguments.length; i++) {
source = arguments[i]
for (var prop in source) {
if (source.hasOwnProperty(prop)) {
destination[prop] = source[prop];
destination[prop] = source[prop]
}
}
}
return destination;
return destination
}
// Internal helper function for Czech language.
function getCzechForm (c) {
if (c === 1) {
return 0
} else if (Math.floor(c) !== c) {
return 1
} else if (c % 10 >= 2 && c % 10 <= 4 && c % 100 < 10) {
return 2
} else {
return 3
}
}
// Internal helper function for Polish language.
function getPolishForm(c) {
function getPolishForm (c) {
if (c === 1) {
return 0;
return 0
} else if (Math.floor(c) !== c) {
return 1;
} else if (2 <= c % 10 && c % 10 <= 4 && !(10 < c % 100 && c % 100 < 20)) {
return 2;
return 1
} else if (c % 10 >= 2 && c % 10 <= 4 && !(c % 100 > 10 && c % 100 < 20)) {
return 2
} else {
return 3;
return 3
}
}
// Internal helper function for Russian language.
function getRussianForm(c) {
// Internal helper function for Russian and Ukranian languages.
function getSlavicForm (c) {
if (Math.floor(c) !== c) {
return 2;
} else if (c === 0 || (c >= 5 && c <= 20) || (c % 10 >= 5 && c % 10 <= 9) || (c % 10 === 0)) {
return 0;
} else if (c === 1 || c % 10 === 1) {
return 1;
return 2
} else if ((c % 100 >= 5 && c % 100 <= 20) || (c % 10 >= 5 && c % 10 <= 9) || c % 10 === 0) {
return 0
} else if (c % 10 === 1) {
return 1
} else if (c > 1) {
return 2;
return 2
} else {
return 0;
return 0
}
}
function getSupportedLanguages() {
var result = [];
// Internal helper function for Lithuanian language.
function getLithuanianForm (c) {
if (c === 1 || (c % 10 === 1 && c % 100 > 20)) {
return 0
} else if (Math.floor(c) !== c || (c % 10 >= 2 && c % 100 > 20) || (c % 10 >= 2 && c % 100 < 10)) {
return 1
} else {
return 2
}
}
humanizeDuration.getSupportedLanguages = function getSupportedLanguages () {
var result = []
for (var language in languages) {
if (languages.hasOwnProperty(language)) {
result.push(language);
result.push(language)
}
}
return result;
return result
}
humanizeDuration.humanizer = humanizer;
humanizeDuration.getSupportedLanguages = getSupportedLanguages;
humanizeDuration.humanizer = humanizer
if (typeof define === "function" && define.amd) {
define(function() {
return humanizeDuration;
});
} else if (typeof module !== "undefined" && module.exports) {
module.exports = humanizeDuration;
if (typeof define === 'function' && define.amd) {
define(function () {
return humanizeDuration
})
} else if (typeof module !== 'undefined' && module.exports) {
module.exports = humanizeDuration
} else {
this.humanizeDuration = humanizeDuration;
this.humanizeDuration = humanizeDuration
}
})();
})(); // eslint-disable-line semi

@@ -1,13 +0,24 @@

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
This is free and unencumbered software released into the public domain.
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
0. You just DO WHAT THE FUCK YOU WANT TO.
For more information, please refer to <http://unlicense.org/>

@@ -5,2 +5,3 @@ {

"contributors": [
"Óli Tómas Freysson (https://github.com/olitomas)",
"Martin Prins (https://github.com/magarcia)",

@@ -13,5 +14,14 @@ "Filipi Siqueira (https://github.com/filipi777)",

"Giovanni Pellerano (https://github.com/evilaliv3)",
"Rahma Sghaier (https://twitter.com/sghaierrahma)"
"Rahma Sghaier (https://twitter.com/sghaierrahma)",
"Evgenios Kastanias (https://github.com/evgenios)",
"Oleksii Mylotskyi (https://github.com/spalax)",
"Matthew Brandly (https://github.com/brandly)",
"Patrik Simek (https://github.com/patriksimek)",
"Toni Helminen (https://github.com/tonihelminen)",
"Vidmantas Drasutis (https://github.com/drasius2)",
"Manh Tuan (https://github.com/J2TeaM)",
"Leonard Lee (https://github.com/sheeeng)",
"Jesse Jackson (https://github.com/jsejcksn)"
],
"version": "2.8.0",
"version": "3.10.0",
"description": "Convert millisecond durations to English and many other languages.",

@@ -21,11 +31,10 @@ "homepage": "https://github.com/EvanHahn/HumanizeDuration.js",

"scripts": {
"test": "mocha",
"hint": "jshint humanize-duration.js"
"pretest": "standard",
"test": "mocha"
},
"devDependencies": {
"coffee-script": "^1.9.2",
"csv-parse": "^0.1.1",
"jshint": "^2.7.0",
"mocha": "^2.2.4",
"ms": "^0.7.1"
"csv-parse": "^1.1.1",
"mocha": "^2.5.3",
"ms": "^0.7.1",
"standard": "^7.1.2"
},

@@ -48,3 +57,11 @@ "keywords": [

"bugs": "https://github.com/EvanHahn/HumanizeDuration.js/issues",
"license": "WTFPL"
"license": "Unlicense",
"standard": {
"globals": [
"define",
"describe",
"it",
"before"
]
}
}
Humanize Duration
=================
[![npm version](https://badge.fury.io/js/humanize-duration.svg)](https://npmjs.org/package/humanize-duration)
[![build status](https://travis-ci.org/EvanHahn/HumanizeDuration.js.svg?branch=master)](https://travis-ci.org/EvanHahn/HumanizeDuration.js)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)

@@ -12,3 +12,3 @@ I have the time in milliseconds and I want it to become "30 minutes" or "3 days, 1 hour". Enter Humanize Duration!

This package is available as *humanize-duration* in npm and Bower. You can also include the JavaScript in the browser.
This package is available as *humanize-duration* on [npm](https://www.npmjs.com/package/humanize-duration) and Bower. You can also include the JavaScript file in the browser.

@@ -27,3 +27,3 @@ In the browser:

```js
var humanizeDuration = require("humanize-duration")
var humanizeDuration = require('humanize-duration')
humanizeDuration(12000)

@@ -38,37 +38,115 @@ ```

```js
humanizeDuration(3000) // "3 seconds"
humanizeDuration(2015) // "2.25 seconds"
humanizeDuration(97320000) // "1 day, 3 hours, 2 minutes"
humanizeDuration(3000) // '3 seconds'
humanizeDuration(2015) // '2.25 seconds'
humanizeDuration(97320000) // '1 day, 3 hours, 2 minutes'
```
### Options
You can change the settings by passing options as the second argument:
**language**
Language for unit display (accepts an [ISO 639-1 code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) from one of the [supported languages](#supported-languages)).
```js
humanizeDuration(3000, { language: "es" }) // "3 segundos"
humanizeDuration(5000, { language: "ko" }) // "5 초"
humanizeDuration(3000, { language: 'es' }) // '3 segundos'
humanizeDuration(5000, { language: 'ko' }) // '5 초'
```
humanizeDuration(22140000, { delimiter: " and " }) // "6 hours and 9 minutes"
humanizeDuration(22140000, { delimiter: "--" }) // "6 hours--9 minutes"
**delimiter**
humanizeDuration(260040000, { spacer: " whole " }) // "3 whole days, 14 whole minutes"
humanizeDuration(260040000, { spacer: "" }) // "3days, 14minutes"
String to display between the previous unit and the next value.
humanizeDuration(3600000, { units: ["hours"] }) // "1 hour"
humanizeDuration(3600000, { units: ["days", "hours"] }) // "1 hour"
humanizeDuration(3600000, { units: ["minutes"] }) // "60 minutes"
```js
humanizeDuration(22140000, { delimiter: ' and ' }) // '6 hours and 9 minutes'
humanizeDuration(22140000, { delimiter: '--' }) // '6 hours--9 minutes'
```
humanizeDuration(1200) // "1.2 seconds"
humanizeDuration(1200, { round: true }) // "1 second"
humanizeDuration(1600, { round: true }) // "2 seconds"
**spacer**
humanizeDuration(150000) // "2.5 minutes"
humanizeDuration(150000, { halfUnit: false }) // "2 minutes, 30 seconds"
String to display between each value and unit.
humanizeDuration(3600000, {
language: "es",
units: ["minutes"]
```js
humanizeDuration(260040000, { spacer: ' whole ' }) // '3 whole days, 14 whole minutes'
humanizeDuration(260040000, { spacer: '' }) // '3days, 14minutes'
```
**largest**
Number representing the maximum number of units to display for the duration.
```js
humanizeDuration(1000000000000) // '31 years, 8 months, 1 week, 19 hours, 46 minutes, 40 seconds'
humanizeDuration(1000000000000, { largest: 2 }) // '31 years, 8 month'
```
**units**
Array of strings to define which units are used to display the duration (if needed). Can be one, or a combination of any, of the following: `['y', 'mo', 'w', 'd', 'h', 'm', 's', 'ms']`
```js
humanizeDuration(3600000, { units: ['h'] }) // '1 hour'
humanizeDuration(3600000, { units: ['m'] }) // '60 minutes'
humanizeDuration(3600000, { units: ['d', 'h'] }) // '1 hour'
```
**round**
Boolean value. Use `true` to [round](https://en.wikipedia.org/wiki/Rounding#Round_half_up) the smallest unit displayed (can be combined with `largest` and `units`).
```js
humanizeDuration(1200) // '1.2 seconds'
humanizeDuration(1200, { round: true }) // '1 second'
humanizeDuration(1600, { round: true }) // '2 seconds'
```
**decimal**
String to substitute for the decimal point in a decimal fraction.
```js
humanizeDuration(1200) // '1.2 seconds'
humanizeDuration(1200, { decimal: ' point ' }) // '1 point 2 seconds'
```
**conjunction**
String to include before the final unit. You can also set `serialComma` to `false` to eliminate the final comma.
```js
humanizeDuration(22140000, { conjunction: ' and ' }) // '6 hours and 9 minutes'
humanizeDuration(22141000, { conjunction: ' and ' }) // '6 hours, 9 minutes, and 1 second'
humanizeDuration(22140000, { conjunction: ' and ', serialComma: false }) // '6 hours and 9 minutes'
humanizeDuration(22141000, { conjunction: ' and ', serialComma: false }) // '6 hours, 9 minutes and 1 second'
```
**unitMeasures**
Customize the value used to calculate each unit of time.
```js
humanizeDuration(400) // '0.4 seconds'
humanizeDuration(400, { // '1 year, 1 month, 5 days'
unitMeasures: {
y: 365,
mo: 30,
w: 7,
d: 1
}
})
// "60 minutos"
```
**Combined example**
```js
humanizeDuration(3602000, {
language: 'es',
round: true,
spacer: ' glorioso ',
units: ['m']
})
// '60 glorioso minutos'
```
### Humanizers

@@ -80,8 +158,8 @@

var spanishHumanizer = humanizeDuration.humanizer({
language: "es",
units: ["years", "months", "days"]
language: 'es',
units: ['y', 'mo', 'd']
})
spanishHumanizer(71177400000) // "2 años, 3 meses, 2 días"
spanishHumanizer(71177400000, { units: ["days", "hours"] }) // "823 días, 19.5 horas"
spanishHumanizer(71177400000) // '2 años, 3 meses, 2 días'
spanishHumanizer(71177400000, { units: ['d', 'h'] }) // '823 días, 19.5 horas'
```

@@ -93,13 +171,13 @@

var shortEnglishHumanizer = humanizeDuration.humanizer({
language: "shortEn",
language: 'shortEn',
languages: {
shortEn: {
year: function() { return "y"; },
month: function() { return "mo"; },
week: function() { return "w"; },
day: function() { return "d"; },
hour: function() { return "h"; },
minute: function() { return "m"; },
second: function() { return "s"; },
millisecond: function() { return "ms"; },
y: function() { return 'y' },
mo: function() { return 'mo' },
w: function() { return 'w' },
d: function() { return 'd' },
h: function() { return 'h' },
m: function() { return 'm' },
s: function() { return 's' },
ms: function() { return 'ms' },
}

@@ -109,3 +187,3 @@ }

shortEnglishHumanizer(15600000) // "4 h, 20 m"
shortEnglishHumanizer(15600000) // '4 h, 20 m'
```

@@ -119,3 +197,3 @@

humanizer.languages.shortEn = {
year: function(c) { return c + "y"; },
y: function(c) { return c + 'y' },
// ...

@@ -131,22 +209,33 @@ ```

* Arabic (ar)
* Catalan (ca)
* Chinese, simplified (zh-CN)
* Chinese, traditional (zh-TW)
* Danish (da)
* Dutch (nl)
* English (en)
* French (fr)
* German (de)
* Hungarian (hu)
* Italian (it)
* Japanese (ja)
* Korean (ko)
* Norwegian (nob)
* Polish (pl)
* Portuguese (pt)
* Russian (ru)
* Spanish (es)
* Swedish (sv)
* Turkish (tr)
| Language | Code |
|----------------------|---------|
| Arabic | `ar` |
| Catalan | `ca` |
| Chinese, simplified | `zh_CN` |
| Chinese, traditional | `zh_TW` |
| Czech | `cs` |
| Danish | `da` |
| Dutch | `nl` |
| English | `en` |
| Finnish | `fi` |
| French | `fr` |
| German | `de` |
| Greek | `gr` |
| Hungarian | `hu` |
| Icelandic | `is` |
| Indonesian | `id` |
| Italian | `it` |
| Japanese | `ja` |
| Korean | `ko` |
| Lithuanian | `lt` |
| Malay | `ms` |
| Norwegian | `no` |
| Polish | `pl` |
| Portuguese | `pt` |
| Russian | `ru` |
| Spanish | `es` |
| Swedish | `sv` |
| Turkish | `tr` |
| Ukrainian | `uk` |
| Vietnamese | `vi` |

@@ -157,5 +246,7 @@ For a list of supported languages, you can use the `getSupportedLanguages` function.

humanizeDuration.getSupportedLanguages()
// ["ar", "ca", "da", "de" ...]
// ['ar', 'ca', 'da', 'de' ...]
```
This function won't return any new languages you define; it will only return the defaults supported by the library.
Credits

@@ -174,3 +265,19 @@ -------

* [Rahma Sghaier](https://twitter.com/sghaierrahma) for Arabic support
* [Evgenios Kastanias](https://github.com/evgenios) for Greek support
* [Oleksii Mylotskyi](https://github.com/spalax) for Ukrainian support
* [Patrik Simek](https://github.com/patriksimek) for Czech support
* [Toni Helminen](https://github.com/tonihelminen) for Finnish support
* [Vidmantas Drasutis](https://github.com/Drasius2) for Lithuanian support
* [Manh Tuan](https://github.com/J2TeaM) for Vietnamese support
* [Leonard Lee](https://github.com/sheeeng) for Indonesian & Malay support
* [Jesse Jackson](https://github.com/jsejcksn) for documentation help
* [Óli Tómas Freysson](https://github.com/olitomas) for Icelandic support
Licensed under the WTFPL, so you can do whatever you want. Enjoy!
Licensed under the permissive [Unlicense](http://unlicense.org/). Enjoy!
Related modules
---------------
* [angularjs-humanize-duration](https://github.com/sebastianhaas/angularjs-humanize-duration)
* [millisec](https://github.com/sungwoncho/millisec)
* [HumanizeDuration.ts](https://github.com/Nightapes/HumanizeDuration.ts), a TypeScript version of this module
{
"author": "Siddique Hameed",
"author": "Adrian Wardell",
"name": "angular-timer",
"version": "1.3.3",
"version": "1.3.5",
"homepage": "https://github.com/siddii/angular-timer",

@@ -13,4 +13,4 @@ "description": "Angular-Timer : A simple AngularJS directive demonstrating re-usability & interoperability",

"angular": ">= 1.0.7",
"momentjs": "~2.9.0",
"humanize-duration": "~2.8.0"
"moment": "~2.9.0",
"humanize-duration": "~3.10.0"
},

@@ -26,3 +26,6 @@ "devDependencies": {

"bower_components"
]
],
"resolutions": {
"moment": "~2.9.0"
}
}

@@ -9,3 +9,3 @@ module.exports = function(config){

'bower_components/humanize-duration/humanize-duration.js',
'bower_components/momentjs/min/moment-with-locales.js',
'bower_components/moment/min/moment-with-locales.js',
'bower_components/angular/angular.js',

@@ -12,0 +12,0 @@ 'bower_components/angular-mocks/angular-mocks.js',

/**
* angular-timer - v1.3.3 - 2015-06-15 3:07 PM
* angular-timer - v1.3.5 - 2017-03-09 2:18 PM
* https://github.com/siddii/angular-timer
*
* Copyright (c) 2015 Siddique Hameed
* Copyright (c) 2017 Adrian Wardell
* Licensed MIT <https://github.com/siddii/angular-timer/blob/master/LICENSE.txt>

@@ -22,3 +22,15 @@ */

fallback: '@?',
maxTimeUnit: '='
maxTimeUnit: '=',
seconds: '=?',
minutes: '=?',
hours: '=?',
days: '=?',
months: '=?',
years: '=?',
secondsS: '=?',
minutesS: '=?',
hoursS: '=?',
daysS: '=?',
monthsS: '=?',
yearsS: '=?'
},

@@ -68,3 +80,3 @@ controller: ['$scope', '$element', '$attrs', '$timeout', 'I18nService', '$interpolate', 'progressBarService', function ($scope, $element, $attrs, $timeout, I18nService, $interpolate, progressBarService) {

$scope.timeoutId = null;
$scope.countdown = $scope.countdownattr && parseInt($scope.countdownattr, 10) >= 0 ? parseInt($scope.countdownattr, 10) : undefined;
$scope.countdown = angular.isNumber($scope.countdownattr) && parseInt($scope.countdownattr, 10) >= 0 ? parseInt($scope.countdownattr, 10) : undefined;
$scope.isRunning = false;

@@ -114,7 +126,7 @@

$scope.start = $element[0].start = function () {
$scope.start = function () {
$scope.startTime = $scope.startTimeAttr ? moment($scope.startTimeAttr) : moment();
$scope.endTime = $scope.endTimeAttr ? moment($scope.endTimeAttr) : null;
if (!$scope.countdown) {
$scope.countdown = $scope.countdownattr && parseInt($scope.countdownattr, 10) > 0 ? parseInt($scope.countdownattr, 10) : undefined;
if (!angular.isNumber($scope.countdown)) {
$scope.countdown = angular.isNumber($scope.countdownattr) && parseInt($scope.countdownattr, 10) > 0 ? parseInt($scope.countdownattr, 10) : undefined;
}

@@ -124,5 +136,13 @@ resetTimeout();

$scope.isRunning = true;
$scope.$emit('timer-started', {
timeoutId: $scope.timeoutId,
millis: $scope.millis,
seconds: $scope.seconds,
minutes: $scope.minutes,
hours: $scope.hours,
days: $scope.days
});
};
$scope.resume = $element[0].resume = function () {
$scope.resume = function () {
resetTimeout();

@@ -135,11 +155,26 @@ if ($scope.countdownattr) {

$scope.isRunning = true;
$scope.$emit('timer-started', {
timeoutId: $scope.timeoutId,
millis: $scope.millis,
seconds: $scope.seconds,
minutes: $scope.minutes,
hours: $scope.hours,
days: $scope.days
});
};
$scope.stop = $scope.pause = $element[0].stop = $element[0].pause = function () {
$scope.stop = $scope.pause = function () {
var timeoutId = $scope.timeoutId;
$scope.clear();
$scope.$emit('timer-stopped', {timeoutId: timeoutId, millis: $scope.millis, seconds: $scope.seconds, minutes: $scope.minutes, hours: $scope.hours, days: $scope.days});
$scope.$emit('timer-stopped', {
timeoutId: timeoutId,
millis: $scope.millis,
seconds: $scope.seconds,
minutes: $scope.minutes,
hours: $scope.hours,
days: $scope.days
});
};
$scope.clear = $element[0].clear = function () {
$scope.clear = function () {
// same as stop but without the event being triggered

@@ -152,6 +187,6 @@ $scope.stoppedTime = moment();

$scope.reset = $element[0].reset = function () {
$scope.reset = function () {
$scope.startTime = $scope.startTimeAttr ? moment($scope.startTimeAttr) : moment();
$scope.endTime = $scope.endTimeAttr ? moment($scope.endTimeAttr) : null;
$scope.countdown = $scope.countdownattr && parseInt($scope.countdownattr, 10) > 0 ? parseInt($scope.countdownattr, 10) : undefined;
$scope.countdown = angular.isNumber($scope.countdownattr) && parseInt($scope.countdownattr, 10) > 0 ? parseInt($scope.countdownattr, 10) : undefined;
resetTimeout();

@@ -161,2 +196,10 @@ tick();

$scope.clear();
$scope.$emit('timer-reset', {
timeoutId: timeoutId,
millis: $scope.millis,
seconds: $scope.seconds,
minutes: $scope.minutes,
hours: $scope.hours,
days: $scope.days
});
};

@@ -254,5 +297,4 @@

$scope.addCDSeconds = $element[0].addCDSeconds = function (extraSeconds) {
$scope.addCDSeconds = function (extraSeconds) {
$scope.countdown += extraSeconds;
$scope.$digest();
if (!$scope.isRunning) {

@@ -264,5 +306,3 @@ $scope.start();

$scope.$on('timer-add-cd-seconds', function (e, extraSeconds) {
$timeout(function () {
$scope.addCDSeconds(extraSeconds);
});
$scope.addCDSeconds(extraSeconds);
});

@@ -313,7 +353,16 @@

$scope.timeoutId = setTimeout(function () {
tick();
$scope.$digest();
tick();
// since you choose not to use $timeout, at least preserve angular cycle two way data binding
// by calling $scope.$apply() instead of $scope.$digest()
$scope.$apply();
}, $scope.interval - adjustment);
$scope.$emit('timer-tick', {timeoutId: $scope.timeoutId, millis: $scope.millis});
$scope.$emit('timer-tick', {
timeoutId: $scope.timeoutId,
millis: $scope.millis,
seconds: $scope.seconds,
minutes: $scope.minutes,
hours: $scope.hours,
days: $scope.days
});

@@ -345,3 +394,46 @@ if ($scope.countdown > 0) {

};
}]);
}])
.directive('timerControls', function() {
return {
restrict: 'EA',
scope: true,
controller: ['$scope', function($scope) {
$scope.timerStatus = "reset";
$scope.$on('timer-started', function() {
$scope.timerStatus = "started";
});
$scope.$on('timer-stopped', function() {
$scope.timerStatus = "stopped";
});
$scope.$on('timer-reset', function() {
$scope.timerStatus = "reset";
});
$scope.timerStart = function() {
$scope.$broadcast('timer-start');
};
$scope.timerStop = function() {
$scope.$broadcast('timer-stop');
};
$scope.timerResume = function() {
$scope.$broadcast('timer-resume');
};
$scope.timerToggle = function() {
switch ($scope.timerStatus) {
case "started":
$scope.timerStop();
break;
case "stopped":
$scope.timerResume();
break;
case "reset":
$scope.timerStart();
break;
}
};
$scope.timerAddCDSeconds = function(extraSeconds) {
$scope.$broadcast('timer-add-cd-seconds', extraSeconds);
};
}]
};
});

@@ -376,4 +468,5 @@ /* commonjs package manager support (eg componentjs) */

//moment init
moment.locale(this.language); //@TODO maybe to remove, it should be handle by the user's application itself, and not inside the directive
// It should be handle by the user's application itself, and not inside the directive
// moment init
// moment.locale(this.language);

@@ -400,9 +493,9 @@ //human duration init, using it because momentjs does not allow accurate time (

time = {
'millis' : this.timeHumanizer(diffFromAlarm, { units: ["milliseconds"] }),
'seconds' : this.timeHumanizer(diffFromAlarm, { units: ["seconds"] }),
'minutes' : this.timeHumanizer(diffFromAlarm, { units: ["minutes", "seconds"] }) ,
'hours' : this.timeHumanizer(diffFromAlarm, { units: ["hours", "minutes", "seconds"] }) ,
'days' : this.timeHumanizer(diffFromAlarm, { units: ["days", "hours", "minutes", "seconds"] }) ,
'months' : this.timeHumanizer(diffFromAlarm, { units: ["months", "days", "hours", "minutes", "seconds"] }) ,
'years' : this.timeHumanizer(diffFromAlarm, { units: ["years", "months", "days", "hours", "minutes", "seconds"] })
'millis' : this.timeHumanizer(diffFromAlarm, { units: ["ms"] }),
'seconds' : this.timeHumanizer(diffFromAlarm, { units: ["s"] }),
'minutes' : this.timeHumanizer(diffFromAlarm, { units: ["m", "s"] }) ,
'hours' : this.timeHumanizer(diffFromAlarm, { units: ["h", "m", "s"] }) ,
'days' : this.timeHumanizer(diffFromAlarm, { units: ["d", "h", "m", "s"] }) ,
'months' : this.timeHumanizer(diffFromAlarm, { units: ["mo", "d", "h", "m", "s"] }) ,
'years' : this.timeHumanizer(diffFromAlarm, { units: ["y", "mo", "d", "h", "m", "s"] })
};

@@ -409,0 +502,0 @@ }

/**
* angular-timer - v1.3.3 - 2015-06-15 3:07 PM
* angular-timer - v1.3.5 - 2017-03-09 2:18 PM
* https://github.com/siddii/angular-timer
*
* Copyright (c) 2015 Siddique Hameed
* Copyright (c) 2017 Adrian Wardell
* Licensed MIT <https://github.com/siddii/angular-timer/blob/master/LICENSE.txt>
*/
var timerModule=angular.module("timer",[]).directive("timer",["$compile",function(a){return{restrict:"EA",replace:!1,scope:{interval:"=interval",startTimeAttr:"=startTime",endTimeAttr:"=endTime",countdownattr:"=countdown",finishCallback:"&finishCallback",autoStart:"&autoStart",language:"@?",fallback:"@?",maxTimeUnit:"="},controller:["$scope","$element","$attrs","$timeout","I18nService","$interpolate","progressBarService",function(b,c,d,e,f,g,h){function i(){b.timeoutId&&clearTimeout(b.timeoutId)}function j(){var a={};void 0!==d.startTime&&(b.millis=moment().diff(moment(b.startTimeAttr))),a=k.getTimeUnits(b.millis),b.maxTimeUnit&&"day"!==b.maxTimeUnit?"second"===b.maxTimeUnit?(b.seconds=Math.floor(b.millis/1e3),b.minutes=0,b.hours=0,b.days=0,b.months=0,b.years=0):"minute"===b.maxTimeUnit?(b.seconds=Math.floor(b.millis/1e3%60),b.minutes=Math.floor(b.millis/6e4),b.hours=0,b.days=0,b.months=0,b.years=0):"hour"===b.maxTimeUnit?(b.seconds=Math.floor(b.millis/1e3%60),b.minutes=Math.floor(b.millis/6e4%60),b.hours=Math.floor(b.millis/36e5),b.days=0,b.months=0,b.years=0):"month"===b.maxTimeUnit?(b.seconds=Math.floor(b.millis/1e3%60),b.minutes=Math.floor(b.millis/6e4%60),b.hours=Math.floor(b.millis/36e5%24),b.days=Math.floor(b.millis/36e5/24%30),b.months=Math.floor(b.millis/36e5/24/30),b.years=0):"year"===b.maxTimeUnit&&(b.seconds=Math.floor(b.millis/1e3%60),b.minutes=Math.floor(b.millis/6e4%60),b.hours=Math.floor(b.millis/36e5%24),b.days=Math.floor(b.millis/36e5/24%30),b.months=Math.floor(b.millis/36e5/24/30%12),b.years=Math.floor(b.millis/36e5/24/365)):(b.seconds=Math.floor(b.millis/1e3%60),b.minutes=Math.floor(b.millis/6e4%60),b.hours=Math.floor(b.millis/36e5%24),b.days=Math.floor(b.millis/36e5/24),b.months=0,b.years=0),b.secondsS=1===b.seconds?"":"s",b.minutesS=1===b.minutes?"":"s",b.hoursS=1===b.hours?"":"s",b.daysS=1===b.days?"":"s",b.monthsS=1===b.months?"":"s",b.yearsS=1===b.years?"":"s",b.secondUnit=a.seconds,b.minuteUnit=a.minutes,b.hourUnit=a.hours,b.dayUnit=a.days,b.monthUnit=a.months,b.yearUnit=a.years,b.sseconds=b.seconds<10?"0"+b.seconds:b.seconds,b.mminutes=b.minutes<10?"0"+b.minutes:b.minutes,b.hhours=b.hours<10?"0"+b.hours:b.hours,b.ddays=b.days<10?"0"+b.days:b.days,b.mmonths=b.months<10?"0"+b.months:b.months,b.yyears=b.years<10?"0"+b.years:b.years}"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),b.autoStart=d.autoStart||d.autostart,b.language=b.language||"en",b.fallback=b.fallback||"en",b.$watch("language",function(a){void 0!==a&&k.init(a,b.fallback)});var k=new f;k.init(b.language,b.fallback),b.displayProgressBar=0,b.displayProgressActive="active",c.append(0===c.html().trim().length?a("<span>"+g.startSymbol()+"millis"+g.endSymbol()+"</span>")(b):a(c.contents())(b)),b.startTime=null,b.endTime=null,b.timeoutId=null,b.countdown=b.countdownattr&&parseInt(b.countdownattr,10)>=0?parseInt(b.countdownattr,10):void 0,b.isRunning=!1,b.$on("timer-start",function(){b.start()}),b.$on("timer-resume",function(){b.resume()}),b.$on("timer-stop",function(){b.stop()}),b.$on("timer-clear",function(){b.clear()}),b.$on("timer-reset",function(){b.reset()}),b.$on("timer-set-countdown",function(a,c){b.countdown=c}),b.$watch("startTimeAttr",function(a,c){a!==c&&b.isRunning&&b.start()}),b.$watch("endTimeAttr",function(a,c){a!==c&&b.isRunning&&b.start()}),b.start=c[0].start=function(){b.startTime=b.startTimeAttr?moment(b.startTimeAttr):moment(),b.endTime=b.endTimeAttr?moment(b.endTimeAttr):null,b.countdown||(b.countdown=b.countdownattr&&parseInt(b.countdownattr,10)>0?parseInt(b.countdownattr,10):void 0),i(),l(),b.isRunning=!0},b.resume=c[0].resume=function(){i(),b.countdownattr&&(b.countdown+=1),b.startTime=moment().diff(moment(b.stoppedTime).diff(moment(b.startTime))),l(),b.isRunning=!0},b.stop=b.pause=c[0].stop=c[0].pause=function(){var a=b.timeoutId;b.clear(),b.$emit("timer-stopped",{timeoutId:a,millis:b.millis,seconds:b.seconds,minutes:b.minutes,hours:b.hours,days:b.days})},b.clear=c[0].clear=function(){b.stoppedTime=moment(),i(),b.timeoutId=null,b.isRunning=!1},b.reset=c[0].reset=function(){b.startTime=b.startTimeAttr?moment(b.startTimeAttr):moment(),b.endTime=b.endTimeAttr?moment(b.endTimeAttr):null,b.countdown=b.countdownattr&&parseInt(b.countdownattr,10)>0?parseInt(b.countdownattr,10):void 0,i(),l(),b.isRunning=!1,b.clear()},c.bind("$destroy",function(){i(),b.isRunning=!1}),b.countdownattr?(b.millis=1e3*b.countdownattr,b.addCDSeconds=c[0].addCDSeconds=function(a){b.countdown+=a,b.$digest(),b.isRunning||b.start()},b.$on("timer-add-cd-seconds",function(a,c){e(function(){b.addCDSeconds(c)})}),b.$on("timer-set-countdown-seconds",function(a,c){b.isRunning||b.clear(),b.countdown=c,b.millis=1e3*c,j()})):b.millis=0,j();var l=function m(){var a=null;b.millis=moment().diff(b.startTime);var c=b.millis%1e3;return b.endTimeAttr&&(a=b.endTimeAttr,b.millis=moment(b.endTime).diff(moment()),c=b.interval-b.millis%1e3),b.countdownattr&&(a=b.countdownattr,b.millis=1e3*b.countdown),b.millis<0?(b.stop(),b.millis=0,j(),void(b.finishCallback&&b.$eval(b.finishCallback))):(j(),b.timeoutId=setTimeout(function(){m(),b.$digest()},b.interval-c),b.$emit("timer-tick",{timeoutId:b.timeoutId,millis:b.millis}),b.countdown>0?b.countdown--:b.countdown<=0&&(b.stop(),b.finishCallback&&b.$eval(b.finishCallback)),void(null!==a&&(b.progressBar=h.calculateProgressBar(b.startTime,b.millis,b.endTime,b.countdownattr),100===b.progressBar&&(b.displayProgressActive=""))))};(void 0===b.autoStart||b.autoStart===!0)&&b.start()}]}}]);"undefined"!=typeof module&&"undefined"!=typeof exports&&module.exports===exports&&(module.exports=timerModule);var app=angular.module("timer");app.factory("I18nService",function(){var a=function(){};return a.prototype.language="en",a.prototype.fallback="en",a.prototype.timeHumanizer={},a.prototype.init=function(a,b){var c=humanizeDuration.getSupportedLanguages();this.fallback=void 0!==b?b:"en",-1===c.indexOf(b)&&(this.fallback="en"),this.language=a,-1===c.indexOf(a)&&(this.language=this.fallback),moment.locale(this.language),this.timeHumanizer=humanizeDuration.humanizer({language:this.language,halfUnit:!1})},a.prototype.getTimeUnits=function(a){var b=1e3*Math.round(a/1e3),c={};return"undefined"!=typeof this.timeHumanizer?c={millis:this.timeHumanizer(b,{units:["milliseconds"]}),seconds:this.timeHumanizer(b,{units:["seconds"]}),minutes:this.timeHumanizer(b,{units:["minutes","seconds"]}),hours:this.timeHumanizer(b,{units:["hours","minutes","seconds"]}),days:this.timeHumanizer(b,{units:["days","hours","minutes","seconds"]}),months:this.timeHumanizer(b,{units:["months","days","hours","minutes","seconds"]}),years:this.timeHumanizer(b,{units:["years","months","days","hours","minutes","seconds"]})}:console.error('i18nService has not been initialized. You must call i18nService.init("en") for example'),c},a});var app=angular.module("timer");app.factory("progressBarService",function(){var a=function(){};return a.prototype.calculateProgressBar=function(a,b,c,d){var e,f,g=0;return b/=1e3,null!==c?(e=moment(c),f=e.diff(a,"seconds"),g=100*b/f):g=100*b/d,g=100-g,g=Math.round(10*g)/10,g>100&&(g=100),g},new a});
var timerModule=angular.module("timer",[]).directive("timer",["$compile",function(a){return{restrict:"EA",replace:!1,scope:{interval:"=interval",startTimeAttr:"=startTime",endTimeAttr:"=endTime",countdownattr:"=countdown",finishCallback:"&finishCallback",autoStart:"&autoStart",language:"@?",fallback:"@?",maxTimeUnit:"=",seconds:"=?",minutes:"=?",hours:"=?",days:"=?",months:"=?",years:"=?",secondsS:"=?",minutesS:"=?",hoursS:"=?",daysS:"=?",monthsS:"=?",yearsS:"=?"},controller:["$scope","$element","$attrs","$timeout","I18nService","$interpolate","progressBarService",function(b,c,d,e,f,g,h){function i(){b.timeoutId&&clearTimeout(b.timeoutId)}function j(){var a={};void 0!==d.startTime&&(b.millis=moment().diff(moment(b.startTimeAttr))),a=k.getTimeUnits(b.millis),b.maxTimeUnit&&"day"!==b.maxTimeUnit?"second"===b.maxTimeUnit?(b.seconds=Math.floor(b.millis/1e3),b.minutes=0,b.hours=0,b.days=0,b.months=0,b.years=0):"minute"===b.maxTimeUnit?(b.seconds=Math.floor(b.millis/1e3%60),b.minutes=Math.floor(b.millis/6e4),b.hours=0,b.days=0,b.months=0,b.years=0):"hour"===b.maxTimeUnit?(b.seconds=Math.floor(b.millis/1e3%60),b.minutes=Math.floor(b.millis/6e4%60),b.hours=Math.floor(b.millis/36e5),b.days=0,b.months=0,b.years=0):"month"===b.maxTimeUnit?(b.seconds=Math.floor(b.millis/1e3%60),b.minutes=Math.floor(b.millis/6e4%60),b.hours=Math.floor(b.millis/36e5%24),b.days=Math.floor(b.millis/36e5/24%30),b.months=Math.floor(b.millis/36e5/24/30),b.years=0):"year"===b.maxTimeUnit&&(b.seconds=Math.floor(b.millis/1e3%60),b.minutes=Math.floor(b.millis/6e4%60),b.hours=Math.floor(b.millis/36e5%24),b.days=Math.floor(b.millis/36e5/24%30),b.months=Math.floor(b.millis/36e5/24/30%12),b.years=Math.floor(b.millis/36e5/24/365)):(b.seconds=Math.floor(b.millis/1e3%60),b.minutes=Math.floor(b.millis/6e4%60),b.hours=Math.floor(b.millis/36e5%24),b.days=Math.floor(b.millis/36e5/24),b.months=0,b.years=0),b.secondsS=1===b.seconds?"":"s",b.minutesS=1===b.minutes?"":"s",b.hoursS=1===b.hours?"":"s",b.daysS=1===b.days?"":"s",b.monthsS=1===b.months?"":"s",b.yearsS=1===b.years?"":"s",b.secondUnit=a.seconds,b.minuteUnit=a.minutes,b.hourUnit=a.hours,b.dayUnit=a.days,b.monthUnit=a.months,b.yearUnit=a.years,b.sseconds=b.seconds<10?"0"+b.seconds:b.seconds,b.mminutes=b.minutes<10?"0"+b.minutes:b.minutes,b.hhours=b.hours<10?"0"+b.hours:b.hours,b.ddays=b.days<10?"0"+b.days:b.days,b.mmonths=b.months<10?"0"+b.months:b.months,b.yyears=b.years<10?"0"+b.years:b.years}"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),b.autoStart=d.autoStart||d.autostart,b.language=b.language||"en",b.fallback=b.fallback||"en",b.$watch("language",function(a,c){void 0!==a&&k.init(a,b.fallback)});var k=new f;k.init(b.language,b.fallback),b.displayProgressBar=0,b.displayProgressActive="active",0===c.html().trim().length?c.append(a("<span>"+g.startSymbol()+"millis"+g.endSymbol()+"</span>")(b)):c.append(a(c.contents())(b)),b.startTime=null,b.endTime=null,b.timeoutId=null,b.countdown=angular.isNumber(b.countdownattr)&&parseInt(b.countdownattr,10)>=0?parseInt(b.countdownattr,10):void 0,b.isRunning=!1,b.$on("timer-start",function(){b.start()}),b.$on("timer-resume",function(){b.resume()}),b.$on("timer-stop",function(){b.stop()}),b.$on("timer-clear",function(){b.clear()}),b.$on("timer-reset",function(){b.reset()}),b.$on("timer-set-countdown",function(a,c){b.countdown=c}),b.$watch("startTimeAttr",function(a,c){a!==c&&b.isRunning&&b.start()}),b.$watch("endTimeAttr",function(a,c){a!==c&&b.isRunning&&b.start()}),b.start=function(){b.startTime=b.startTimeAttr?moment(b.startTimeAttr):moment(),b.endTime=b.endTimeAttr?moment(b.endTimeAttr):null,angular.isNumber(b.countdown)||(b.countdown=angular.isNumber(b.countdownattr)&&parseInt(b.countdownattr,10)>0?parseInt(b.countdownattr,10):void 0),i(),l(),b.isRunning=!0,b.$emit("timer-started",{timeoutId:b.timeoutId,millis:b.millis,seconds:b.seconds,minutes:b.minutes,hours:b.hours,days:b.days})},b.resume=function(){i(),b.countdownattr&&(b.countdown+=1),b.startTime=moment().diff(moment(b.stoppedTime).diff(moment(b.startTime))),l(),b.isRunning=!0,b.$emit("timer-started",{timeoutId:b.timeoutId,millis:b.millis,seconds:b.seconds,minutes:b.minutes,hours:b.hours,days:b.days})},b.stop=b.pause=function(){var a=b.timeoutId;b.clear(),b.$emit("timer-stopped",{timeoutId:a,millis:b.millis,seconds:b.seconds,minutes:b.minutes,hours:b.hours,days:b.days})},b.clear=function(){b.stoppedTime=moment(),i(),b.timeoutId=null,b.isRunning=!1},b.reset=function(){b.startTime=b.startTimeAttr?moment(b.startTimeAttr):moment(),b.endTime=b.endTimeAttr?moment(b.endTimeAttr):null,b.countdown=angular.isNumber(b.countdownattr)&&parseInt(b.countdownattr,10)>0?parseInt(b.countdownattr,10):void 0,i(),l(),b.isRunning=!1,b.clear(),b.$emit("timer-reset",{timeoutId:timeoutId,millis:b.millis,seconds:b.seconds,minutes:b.minutes,hours:b.hours,days:b.days})},c.bind("$destroy",function(){i(),b.isRunning=!1}),b.countdownattr?(b.millis=1e3*b.countdownattr,b.addCDSeconds=function(a){b.countdown+=a,b.isRunning||b.start()},b.$on("timer-add-cd-seconds",function(a,c){b.addCDSeconds(c)}),b.$on("timer-set-countdown-seconds",function(a,c){b.isRunning||b.clear(),b.countdown=c,b.millis=1e3*c,j()})):b.millis=0,j();var l=function m(){var a=null;b.millis=moment().diff(b.startTime);var c=b.millis%1e3;return b.endTimeAttr&&(a=b.endTimeAttr,b.millis=moment(b.endTime).diff(moment()),c=b.interval-b.millis%1e3),b.countdownattr&&(a=b.countdownattr,b.millis=1e3*b.countdown),b.millis<0?(b.stop(),b.millis=0,j(),void(b.finishCallback&&b.$eval(b.finishCallback))):(j(),b.timeoutId=setTimeout(function(){m(),b.$apply()},b.interval-c),b.$emit("timer-tick",{timeoutId:b.timeoutId,millis:b.millis,seconds:b.seconds,minutes:b.minutes,hours:b.hours,days:b.days}),b.countdown>0?b.countdown--:b.countdown<=0&&(b.stop(),b.finishCallback&&b.$eval(b.finishCallback)),void(null!==a&&(b.progressBar=h.calculateProgressBar(b.startTime,b.millis,b.endTime,b.countdownattr),100===b.progressBar&&(b.displayProgressActive=""))))};(void 0===b.autoStart||b.autoStart===!0)&&b.start()}]}}]).directive("timerControls",function(){return{restrict:"EA",scope:!0,controller:["$scope",function(a){a.timerStatus="reset",a.$on("timer-started",function(){a.timerStatus="started"}),a.$on("timer-stopped",function(){a.timerStatus="stopped"}),a.$on("timer-reset",function(){a.timerStatus="reset"}),a.timerStart=function(){a.$broadcast("timer-start")},a.timerStop=function(){a.$broadcast("timer-stop")},a.timerResume=function(){a.$broadcast("timer-resume")},a.timerToggle=function(){switch(a.timerStatus){case"started":a.timerStop();break;case"stopped":a.timerResume();break;case"reset":a.timerStart()}},a.timerAddCDSeconds=function(b){a.$broadcast("timer-add-cd-seconds",b)}}]}});"undefined"!=typeof module&&"undefined"!=typeof exports&&module.exports===exports&&(module.exports=timerModule);var app=angular.module("timer");app.factory("I18nService",function(){var a=function(){};return a.prototype.language="en",a.prototype.fallback="en",a.prototype.timeHumanizer={},a.prototype.init=function(a,b){var c=humanizeDuration.getSupportedLanguages();this.fallback=void 0!==b?b:"en",-1===c.indexOf(b)&&(this.fallback="en"),this.language=a,-1===c.indexOf(a)&&(this.language=this.fallback),this.timeHumanizer=humanizeDuration.humanizer({language:this.language,halfUnit:!1})},a.prototype.getTimeUnits=function(a){var b=1e3*Math.round(a/1e3),c={};return"undefined"!=typeof this.timeHumanizer?c={millis:this.timeHumanizer(b,{units:["ms"]}),seconds:this.timeHumanizer(b,{units:["s"]}),minutes:this.timeHumanizer(b,{units:["m","s"]}),hours:this.timeHumanizer(b,{units:["h","m","s"]}),days:this.timeHumanizer(b,{units:["d","h","m","s"]}),months:this.timeHumanizer(b,{units:["mo","d","h","m","s"]}),years:this.timeHumanizer(b,{units:["y","mo","d","h","m","s"]})}:console.error('i18nService has not been initialized. You must call i18nService.init("en") for example'),c},a});var app=angular.module("timer");app.factory("progressBarService",function(){var a=function(){};return a.prototype.calculateProgressBar=function(a,b,c,d){var e,f,g=0;return b/=1e3,null!==c?(e=moment(c),f=e.diff(a,"seconds"),g=100*b/f):g=100*b/d,g=100-g,g=Math.round(10*g)/10,g>100&&(g=100),g},new a});

@@ -1,28 +0,1 @@

function startTimer(sectionId) {
document.getElementById(sectionId).getElementsByTagName('timer')[0].start();
}
function stopTimer(sectionId) {
document.getElementById(sectionId).getElementsByTagName('timer')[0].stop();
}
function addCDSeconds(sectionId, extraTime) {
document.getElementById(sectionId).getElementsByTagName('timer')[0].addCDSeconds(extraTime);
}
function stopResumeTimer(sectionId, btn) {
if (btn.innerHTML === 'Start') {
document.getElementById(sectionId).getElementsByTagName('timer')[0].start();
btn.innerHTML = 'Stop';
}
else if (btn.innerHTML === 'Stop') {
document.getElementById(sectionId).getElementsByTagName('timer')[0].stop();
btn.innerHTML = 'Resume';
}
else {
document.getElementById(sectionId).getElementsByTagName('timer')[0].resume();
btn.innerHTML = 'Stop';
}
}
angular.module('timer-demo',['timer']).controller('TimerDemoController',['$scope', function ($scope) {

@@ -37,6 +10,17 @@ $scope.linkAnchors = function () {

};
$scope.btnText = {
reset: "Start",
started: "Stop",
stopped: "Resume"
};
$scope.currentYear = (new Date).getFullYear();
$scope.startTime = (new Date($scope.currentYear, 0, 1)).getTime();
$scope.endYear = $scope.currentYear+1;
$scope.endTime = (new Date($scope.endYear, 0, 1)).getTime();
$scope.callbackTimer={};
$scope.callbackTimer.status='Running';
$scope.callbackTimer.callbackCount=0;
$scope.callbackTimer.callbackCount=0;
$scope.callbackTimer.finished=function(){

@@ -43,0 +27,0 @@ $scope.callbackTimer.status='COMPLETE!!';

@@ -70,3 +70,3 @@ module.exports = function (grunt) {

'<%= dist_dir %>/<%= pkg.name %>.min.js',
'bower_components/momentjs/min/moment-with-locales.min.js',
'bower_components/moment/min/moment-with-locales.min.js',
'bower_components/humanize-duration/humanize-duration.js'

@@ -147,3 +147,3 @@ ],

port: 3030,
base: 'dist'
base: '.'
}

@@ -150,0 +150,0 @@ }

{
"author": "Siddique Hameed",
"author": "Adrian Wardell",
"name": "angular-timer",
"version": "1.3.3",
"version": "1.3.5",
"homepage": "https://github.com/siddii/angular-timer",
"main": "dist/angular-timer.js",
"license": "MIT",
"licenses": {

@@ -8,0 +9,0 @@ "type": "MIT",

@@ -116,3 +116,3 @@ 'use strict';

it('End Time Timer - Ends at beginning of 2014', function () {
it('End Time Timer - Ends at beginning of next year', function () {
var beforeTime = element('#timer-with-end-time timer span').html();

@@ -119,0 +119,0 @@ sleep(3);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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