Skip to content

Commit

Permalink
v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
siddii committed Mar 3, 2015
1 parent 5078081 commit 43706f6
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 59 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-##Change Log

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

###Version 1.2.1
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "Siddique Hameed",
"name": "angular-timer",
"version": "1.2.2",
"version": "1.3.0",
"homepage": "https://github.com/siddii/angular-timer",
"description": "Angular-Timer : A simple AngularJS directive demonstrating re-usability & interoperability",
"repository": {
Expand Down
108 changes: 54 additions & 54 deletions dist/angular-timer.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,63 @@
/**
* angular-timer - v1.2.2 - 2015-03-03 1:43 PM
* angular-timer - v1.3.0 - 2015-03-03 5:32 PM
* https://github.com/siddii/angular-timer
*
* Copyright (c) 2015 Siddique Hameed
* Licensed MIT <https://github.com/siddii/angular-timer/blob/master/LICENSE.txt>
*/
var app = angular.module('timer');

app.factory('I18nService', function() {

var I18nService = function() {};

I18nService.prototype.language = 'en';
I18nService.prototype.timeHumanizer = {};

I18nService.prototype.init = function init(lang){
this.language = lang;
//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

//human duration init, using it because momentjs does not allow accurate time (
// momentJS: a few moment ago, human duration : 4 seconds ago
this.timeHumanizer = humanizeDuration.humanizer({
language: this.language,
halfUnit:false
});
};

/**
* get time with units from momentJS i18n
* @param {int} millis
* @returns {{millis: string, seconds: string, minutes: string, hours: string, days: string, months: string, years: string}}
*/
I18nService.prototype.getTimeUnits = function getTimeUnits(millis) {
var diffFromAlarm = Math.round(millis/1000) * 1000; //time in milliseconds, get rid of the last 3 ms value to avoid 2.12 seconds display

var time = {};

if (typeof this.timeHumanizer != 'undefined'){
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"] })
};
}
else {
console.error('i18nService has not been initialized. You must call i18nService.init("en") for example');
}

return time;
};

return I18nService;
});

var timerModule = angular.module('timer', [])
.directive('timer', ['$compile', function ($compile) {
return {
Expand Down Expand Up @@ -313,56 +366,3 @@ var timerModule = angular.module('timer', [])
if (typeof module !== "undefined" && typeof exports !== "undefined" && module.exports === exports){
module.exports = timerModule;
}

var app = angular.module('timer');

app.factory('I18nService', function() {

var I18nService = function() {};

I18nService.prototype.language = 'en';
I18nService.prototype.timeHumanizer = {};

I18nService.prototype.init = function init(lang){
this.language = lang;
//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

//human duration init, using it because momentjs does not allow accurate time (
// momentJS: a few moment ago, human duration : 4 seconds ago
this.timeHumanizer = humanizeDuration.humanizer({
language: this.language,
halfUnit:false
});
};

/**
* get time with units from momentJS i18n
* @param {int} millis
* @returns {{millis: string, seconds: string, minutes: string, hours: string, days: string, months: string, years: string}}
*/
I18nService.prototype.getTimeUnits = function getTimeUnits(millis) {
var diffFromAlarm = Math.round(millis/1000) * 1000; //time in milliseconds, get rid of the last 3 ms value to avoid 2.12 seconds display

var time = {};

if (typeof this.timeHumanizer != 'undefined'){
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"] })
};
}
else {
console.error('i18nService has not been initialized. You must call i18nService.init("en") for example');
}

return time;
};

return I18nService;
});
4 changes: 2 additions & 2 deletions dist/angular-timer.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "Siddique Hameed",
"name": "angular-timer",
"version": "1.2.2",
"version": "1.3.0",
"homepage": "https://github.com/siddii/angular-timer",
"main":"dist/angular-timer.js",
"licenses": {
Expand Down

0 comments on commit 43706f6

Please sign in to comment.