Skip to content

Commit 43706f6

Browse files
committed
v1.3.0
1 parent 5078081 commit 43706f6

File tree

5 files changed

+59
-59
lines changed

5 files changed

+59
-59
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-##Change Log
22

3-
###Version 1.2.2
3+
###Version 1.3.0
44
* MomentJS integration - https://github.com/siddii/angular-timer/pull/159
55

66
###Version 1.2.1

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"author": "Siddique Hameed",
33
"name": "angular-timer",
4-
"version": "1.2.2",
4+
"version": "1.3.0",
55
"homepage": "https://github.com/siddii/angular-timer",
66
"description": "Angular-Timer : A simple AngularJS directive demonstrating re-usability & interoperability",
77
"repository": {

dist/angular-timer.js

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,63 @@
11
/**
2-
* angular-timer - v1.2.2 - 2015-03-03 1:43 PM
2+
* angular-timer - v1.3.0 - 2015-03-03 5:32 PM
33
* https://github.com/siddii/angular-timer
44
*
55
* Copyright (c) 2015 Siddique Hameed
66
* Licensed MIT <https://github.com/siddii/angular-timer/blob/master/LICENSE.txt>
77
*/
8+
var app = angular.module('timer');
9+
10+
app.factory('I18nService', function() {
11+
12+
var I18nService = function() {};
13+
14+
I18nService.prototype.language = 'en';
15+
I18nService.prototype.timeHumanizer = {};
16+
17+
I18nService.prototype.init = function init(lang){
18+
this.language = lang;
19+
//moment init
20+
moment.locale(this.language); //@TODO maybe to remove, it should be handle by the user's application itself, and not inside the directive
21+
22+
//human duration init, using it because momentjs does not allow accurate time (
23+
// momentJS: a few moment ago, human duration : 4 seconds ago
24+
this.timeHumanizer = humanizeDuration.humanizer({
25+
language: this.language,
26+
halfUnit:false
27+
});
28+
};
29+
30+
/**
31+
* get time with units from momentJS i18n
32+
* @param {int} millis
33+
* @returns {{millis: string, seconds: string, minutes: string, hours: string, days: string, months: string, years: string}}
34+
*/
35+
I18nService.prototype.getTimeUnits = function getTimeUnits(millis) {
36+
var diffFromAlarm = Math.round(millis/1000) * 1000; //time in milliseconds, get rid of the last 3 ms value to avoid 2.12 seconds display
37+
38+
var time = {};
39+
40+
if (typeof this.timeHumanizer != 'undefined'){
41+
time = {
42+
'millis' : this.timeHumanizer(diffFromAlarm, { units: ["milliseconds"] }),
43+
'seconds' : this.timeHumanizer(diffFromAlarm, { units: ["seconds"] }),
44+
'minutes' : this.timeHumanizer(diffFromAlarm, { units: ["minutes", "seconds"] }) ,
45+
'hours' : this.timeHumanizer(diffFromAlarm, { units: ["hours", "minutes", "seconds"] }) ,
46+
'days' : this.timeHumanizer(diffFromAlarm, { units: ["days", "hours", "minutes", "seconds"] }) ,
47+
'months' : this.timeHumanizer(diffFromAlarm, { units: ["months", "days", "hours", "minutes", "seconds"] }) ,
48+
'years' : this.timeHumanizer(diffFromAlarm, { units: ["years", "months", "days", "hours", "minutes", "seconds"] })
49+
};
50+
}
51+
else {
52+
console.error('i18nService has not been initialized. You must call i18nService.init("en") for example');
53+
}
54+
55+
return time;
56+
};
57+
58+
return I18nService;
59+
});
60+
861
var timerModule = angular.module('timer', [])
962
.directive('timer', ['$compile', function ($compile) {
1063
return {
@@ -313,56 +366,3 @@ var timerModule = angular.module('timer', [])
313366
if (typeof module !== "undefined" && typeof exports !== "undefined" && module.exports === exports){
314367
module.exports = timerModule;
315368
}
316-
317-
var app = angular.module('timer');
318-
319-
app.factory('I18nService', function() {
320-
321-
var I18nService = function() {};
322-
323-
I18nService.prototype.language = 'en';
324-
I18nService.prototype.timeHumanizer = {};
325-
326-
I18nService.prototype.init = function init(lang){
327-
this.language = lang;
328-
//moment init
329-
moment.locale(this.language); //@TODO maybe to remove, it should be handle by the user's application itself, and not inside the directive
330-
331-
//human duration init, using it because momentjs does not allow accurate time (
332-
// momentJS: a few moment ago, human duration : 4 seconds ago
333-
this.timeHumanizer = humanizeDuration.humanizer({
334-
language: this.language,
335-
halfUnit:false
336-
});
337-
};
338-
339-
/**
340-
* get time with units from momentJS i18n
341-
* @param {int} millis
342-
* @returns {{millis: string, seconds: string, minutes: string, hours: string, days: string, months: string, years: string}}
343-
*/
344-
I18nService.prototype.getTimeUnits = function getTimeUnits(millis) {
345-
var diffFromAlarm = Math.round(millis/1000) * 1000; //time in milliseconds, get rid of the last 3 ms value to avoid 2.12 seconds display
346-
347-
var time = {};
348-
349-
if (typeof this.timeHumanizer != 'undefined'){
350-
time = {
351-
'millis' : this.timeHumanizer(diffFromAlarm, { units: ["milliseconds"] }),
352-
'seconds' : this.timeHumanizer(diffFromAlarm, { units: ["seconds"] }),
353-
'minutes' : this.timeHumanizer(diffFromAlarm, { units: ["minutes", "seconds"] }) ,
354-
'hours' : this.timeHumanizer(diffFromAlarm, { units: ["hours", "minutes", "seconds"] }) ,
355-
'days' : this.timeHumanizer(diffFromAlarm, { units: ["days", "hours", "minutes", "seconds"] }) ,
356-
'months' : this.timeHumanizer(diffFromAlarm, { units: ["months", "days", "hours", "minutes", "seconds"] }) ,
357-
'years' : this.timeHumanizer(diffFromAlarm, { units: ["years", "months", "days", "hours", "minutes", "seconds"] })
358-
};
359-
}
360-
else {
361-
console.error('i18nService has not been initialized. You must call i18nService.init("en") for example');
362-
}
363-
364-
return time;
365-
};
366-
367-
return I18nService;
368-
});

dist/angular-timer.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"author": "Siddique Hameed",
33
"name": "angular-timer",
4-
"version": "1.2.2",
4+
"version": "1.3.0",
55
"homepage": "https://github.com/siddii/angular-timer",
66
"main":"dist/angular-timer.js",
77
"licenses": {

0 commit comments

Comments
 (0)