[Lada-commits] [PATCH] Fixed exponential number format
Wald Commits
scm-commit at wald.intevation.org
Thu Mar 31 11:44:01 CEST 2016
# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1459417443 -7200
# Node ID 1d20cec263eedd272c30d8d940b6869f7372be24
# Parent 096d552508cd3c7ef3894b247b2d1c8c8cb84b56
Fixed exponential number format.
diff -r 096d552508cd -r 1d20cec263ee app/model/Messwert.js
--- a/app/model/Messwert.js Thu Mar 24 09:49:28 2016 +0100
+++ b/app/model/Messwert.js Thu Mar 31 11:44:03 2016 +0200
@@ -59,8 +59,18 @@
var parts = tmp.split('e');
if (parts[0].indexOf('.') > 0) {
var floatPart = parseFloat(parts[0]);
- var separator = floatPart.toLocaleString().replace(/[-\d]/g, '');
- parts[0] = floatPart.toFixed(3).replace('.', separator);
+ var separator = floatPart.toFixed(2).toLocaleString().replace(/[-\d]/g, '');
+ parts[0] = floatPart.toFixed(2).replace('.', separator);
+ }
+ else if (parts[0].indexOf(',') < 0) {
+ parts[0] = parts[0] + ',00';
+ }
+ var intPart = parseInt(parts[1]);
+ if (intPart < 10 && intPart >= 0) {
+ parts[1] = '+0' + parseInt(parts[1]);
+ }
+ else if (intPart < 0 && intPart > -10) {
+ parts[1] = parts[1].replace('-', '-0');
}
return parts[0] + 'e' + parts[1];
}
@@ -110,7 +120,18 @@
var parts = tmp.split('e');
if (parts[0].indexOf('.') > 0) {
var floatPart = parseFloat(parts[0]);
- parts[0] = floatPart.toLocaleString();
+ var separator = floatPart.toFixed(2).toLocaleString().replace(/[-\d]/g, '');
+ parts[0] = floatPart.toFixed(2).replace('.', separator);
+ }
+ else if (parts[0].indexOf(',') < 0) {
+ parts[0] = parts[0] + ',00';
+ }
+ var intPart = parseInt(parts[1]);
+ if (intPart < 10 && intPart >= 0) {
+ parts[1] = '+0' + parseInt(parts[1]);
+ }
+ else if (intPart < 0 && intPart > -10) {
+ parts[1] = parts[1].replace('-', '-0');
}
return parts[0] + 'e' + parts[1];
}
diff -r 096d552508cd -r 1d20cec263ee app/model/Zusatzwert.js
--- a/app/model/Zusatzwert.js Thu Mar 24 09:49:28 2016 +0100
+++ b/app/model/Zusatzwert.js Thu Mar 31 11:44:03 2016 +0200
@@ -56,8 +56,18 @@
var parts = tmp.split('e');
if (parts[0].indexOf('.') > 0) {
var floatPart = parseFloat(parts[0]);
- var separator = floatPart.toLocaleString().replace(/[-\d]/g, '');
- parts[0] = floatPart.toFixed(3).replace('.', separator);
+ var separator = floatPart.toFixed(2).toLocaleString().replace(/[-\d]/g, '');
+ parts[0] = floatPart.toFixed(2).replace('.', separator);
+ }
+ else if (parts[0].indexOf(',') < 0) {
+ parts[0] = parts[0] + ',00';
+ }
+ var intPart = parseInt(parts[1]);
+ if (intPart < 10 && intPart >= 0) {
+ parts[1] = '+0' + parseInt(parts[1]);
+ }
+ else if (intPart < 0 && intPart > -10) {
+ parts[1] = parts[1].replace('-', '-0');
}
return parts[0] + 'e' + parts[1];
}
@@ -92,8 +102,18 @@
var parts = tmp.split('e');
if (parts[0].indexOf('.') > 0) {
var floatPart = parseFloat(parts[0]);
- var separator = floatPart.toLocaleString().replace(/[-\d]/g, '');
- parts[0] = floatPart.toFixed(3).replace('.', separator);
+ var separator = floatPart.toFixed(2).toLocaleString().replace(/[-\d]/g, '');
+ parts[0] = floatPart.toFixed(2).replace('.', separator);
+ }
+ else if (parts[0].indexOf(',') < 0) {
+ parts[0] = parts[0] + ',00';
+ }
+ var intPart = parseInt(parts[1]);
+ if (intPart < 10 && intPart >= 0) {
+ parts[1] = '+0' + parseInt(parts[1]);
+ }
+ else if (intPart < 0 && intPart > -10) {
+ parts[1] = parts[1].replace('-', '-0');
}
return parts[0] + 'e' + parts[1];
}
More information about the Lada-commits
mailing list