You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2022/10/07 12:50:55 UTC
[brooklyn-ui] branch master updated (9e5644e5 -> e779260f)
This is an automated email from the ASF dual-hosted git repository.
heneveld pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-ui.git
from 9e5644e5 improve schema for blueprint import
new d41dc8de fix dangling usage of imprecise moment
new e779260f fix rounding error in moment with negative duration
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../home/app/views/about/about.controller.js | 4 ++--
ui-modules/utils/utils/momentp.js | 24 +++++++++++-----------
2 files changed, 14 insertions(+), 14 deletions(-)
[brooklyn-ui] 02/02: fix rounding error in moment with negative duration
Posted by he...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-ui.git
commit e779260f0815ba82316a07b1191bcaae12df5430
Author: Alex Heneveld <al...@cloudsoft.io>
AuthorDate: Fri Oct 7 13:50:01 2022 +0100
fix rounding error in moment with negative duration
---
ui-modules/utils/utils/momentp.js | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/ui-modules/utils/utils/momentp.js b/ui-modules/utils/utils/momentp.js
index 523dcdae..d8691736 100644
--- a/ui-modules/utils/utils/momentp.js
+++ b/ui-modules/utils/utils/momentp.js
@@ -69,7 +69,7 @@ export class MomentPrecise {
if (millis < 0) {
millis = -millis;
tweak = x=> {
- return this.capitalized("-" + x.replace(/ /g, ""));
+ return "- " + this.capitalize(x);
}
}
@@ -77,8 +77,8 @@ export class MomentPrecise {
let secs = millis/1000;
let secsR = Math.round(secs);
- if (secsR < 10) return tweak(rounded(secs, 1)+"s");
- if (secsR < 60) return tweak(secsR+"s");
+ if (secs < 10) return tweak(rounded(secs, 1)+"s");
+ if (secs < 60) return tweak(secsR+"s");
let mins = Math.floor(secs/60);
let minsR = Math.round(secs/60);
@@ -90,32 +90,32 @@ export class MomentPrecise {
if (mins < 5) {
return tweak(mins +"m" + " " + secs +"s");
}
- if (minsR < 60) {
+ if (mins < 60) {
return tweak(minsR) +" mins";
}
- let hours = Math.floor(minsR/60);
- let hoursR = Math.round(minsR/60);
+ let hours = Math.floor(mins/60);
+ let hoursR = Math.round(mins/60);
mins = Math.round(mins - hours*60);
if (mins >= 60) {
hours++;
mins -= 60;
}
if (hours < 4) return tweak(hours +"h" +" " + mins +"m");
- if (hoursR < 24) return tweak(hoursR) +" hours";
+ if (hours < 24) return tweak(hoursR) +" hours";
- let days = Math.floor(hoursR/24);
- let daysR = Math.round(hoursR/24);
+ let days = Math.floor(hours/24);
+ let daysR = Math.round(hours/24);
hours = Math.round(hours - days*24);
if (hours >= 24) {
days++;
hours -= 24;
}
if (days < 7) return tweak(days + "d" +" " + hours +"h");
- if (daysR < 365) return tweak(daysR) + " days";
+ if (days < 365) return tweak(daysR) + " days";
- let years = Math.floor(daysR / 365.25);
- let yearsR = Math.round(daysR / 365.25);
+ let years = Math.floor(days / 365.25);
+ let yearsR = Math.round(days / 365.25);
days = Math.round(days - years*365.25);
if (days >= 365) {
years += 1;
[brooklyn-ui] 01/02: fix dangling usage of imprecise moment
Posted by he...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-ui.git
commit d41dc8de64181a64f1b9e71d8ea9e4c8afa77cc1
Author: Alex Heneveld <al...@cloudsoft.io>
AuthorDate: Tue Oct 4 12:10:19 2022 +0100
fix dangling usage of imprecise moment
---
ui-modules/home/app/views/about/about.controller.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ui-modules/home/app/views/about/about.controller.js b/ui-modules/home/app/views/about/about.controller.js
index 6b675e75..727da541 100644
--- a/ui-modules/home/app/views/about/about.controller.js
+++ b/ui-modules/home/app/views/about/about.controller.js
@@ -18,7 +18,7 @@
*/
import angular from 'angular';
-import moment from "moment";
+import { fromNow } from "brooklyn-ui-utils/utils/momentp";
import { get } from 'lodash';
import uiRouter from 'angular-ui-router';
import uibModal from 'angular-ui-bootstrap/src/modal/index-nocss';
@@ -252,7 +252,7 @@ export function aboutStateController($scope, $rootScope, $element, $q, $uibModal
export function timeAgoFilter() {
return function (input) {
if (input) {
- return moment(input).fromNow();
+ return fromNow(input);
}
}
}