Skip to content

Commit ad3c984

Browse files
committed
FIX: humanizer units format according to humanize-duration v3.1.0+
Removed moment.locale setting to prevent unwanted side effects on users moment.locale settings.
1 parent a704c4e commit ad3c984

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

app/js/i18nService.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ app.factory('I18nService', function() {
2121
this.language = this.fallback;
2222
}
2323

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

2728
//human duration init, using it because momentjs does not allow accurate time (
2829
// momentJS: a few moment ago, human duration : 4 seconds ago
@@ -44,13 +45,13 @@ app.factory('I18nService', function() {
4445

4546
if (typeof this.timeHumanizer != 'undefined'){
4647
time = {
47-
'millis' : this.timeHumanizer(diffFromAlarm, { units: ["milliseconds"] }),
48-
'seconds' : this.timeHumanizer(diffFromAlarm, { units: ["seconds"] }),
49-
'minutes' : this.timeHumanizer(diffFromAlarm, { units: ["minutes", "seconds"] }) ,
50-
'hours' : this.timeHumanizer(diffFromAlarm, { units: ["hours", "minutes", "seconds"] }) ,
51-
'days' : this.timeHumanizer(diffFromAlarm, { units: ["days", "hours", "minutes", "seconds"] }) ,
52-
'months' : this.timeHumanizer(diffFromAlarm, { units: ["months", "days", "hours", "minutes", "seconds"] }) ,
53-
'years' : this.timeHumanizer(diffFromAlarm, { units: ["years", "months", "days", "hours", "minutes", "seconds"] })
48+
'millis' : this.timeHumanizer(diffFromAlarm, { units: ["ms"] }),
49+
'seconds' : this.timeHumanizer(diffFromAlarm, { units: ["s"] }),
50+
'minutes' : this.timeHumanizer(diffFromAlarm, { units: ["m", "s"] }) ,
51+
'hours' : this.timeHumanizer(diffFromAlarm, { units: ["h", "m", "s"] }) ,
52+
'days' : this.timeHumanizer(diffFromAlarm, { units: ["d", "h", "m", "s"] }) ,
53+
'months' : this.timeHumanizer(diffFromAlarm, { units: ["mo", "d", "h", "m", "s"] }) ,
54+
'years' : this.timeHumanizer(diffFromAlarm, { units: ["y", "mo", "d", "h", "m", "s"] })
5455
};
5556
}
5657
else {

0 commit comments

Comments
 (0)