summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2016-03-05 10:32:57 +0100
committerMichael Stahl <mstahl@redhat.com>2016-03-07 12:30:42 +0000
commitf0b889e37f2e40163a02c6ca65c4962fa699b383 (patch)
tree5b4b81bdfe97197d71174ff42fa32952a3f26617
parent432a05e749660ebcfd11ebd2aedbde169ce03f0b (diff)
tdf#97462 reportbuilder SECOND() force rounding to nearest nanosecond
Change-Id: I690a81997c79956fc19ddf83f958768d5e7a313e Reviewed-on: https://gerrit.libreoffice.org/22930 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r--external/jfreereport/UnpackedTarball_jfreereport_libformula.mk1
-rw-r--r--external/jfreereport/patches/libformula-seconds_rounding.patch.137
2 files changed, 38 insertions, 0 deletions
diff --git a/external/jfreereport/UnpackedTarball_jfreereport_libformula.mk b/external/jfreereport/UnpackedTarball_jfreereport_libformula.mk
index ec9d29d3b58c..59622966895a 100644
--- a/external/jfreereport/UnpackedTarball_jfreereport_libformula.mk
+++ b/external/jfreereport/UnpackedTarball_jfreereport_libformula.mk
@@ -18,6 +18,7 @@ $(eval $(call gb_UnpackedTarball_fix_end_of_line,jfreereport_libformula,\
$(eval $(call gb_UnpackedTarball_add_patches,jfreereport_libformula,\
external/jfreereport/patches/common_build.patch \
external/jfreereport/patches/libformula-time-notz.patch \
+ external/jfreereport/patches/libformula-seconds_rounding.patch.1 \
external/jfreereport/patches/libformula-minutes_truncation.patch.1 \
external/jfreereport/patches/libformula-datevalue_truncation.patch.1 \
))
diff --git a/external/jfreereport/patches/libformula-seconds_rounding.patch.1 b/external/jfreereport/patches/libformula-seconds_rounding.patch.1
new file mode 100644
index 000000000000..369332d1a8f0
--- /dev/null
+++ b/external/jfreereport/patches/libformula-seconds_rounding.patch.1
@@ -0,0 +1,37 @@
+diff -ur jfreereport_libformula.org/source/org/pentaho/reporting/libraries/formula/function/datetime/SecondFunction.java jfreereport_libformula/source/org/pentaho/reporting/libraries/formula/function/datetime/SecondFunction.java
+--- jfreereport_libformula.org/source/org/pentaho/reporting/libraries/formula/function/datetime/SecondFunction.java 2016-03-05 09:43:06.121774691 +0100
++++ jfreereport_libformula/source/org/pentaho/reporting/libraries/formula/function/datetime/SecondFunction.java 2016-03-05 09:51:04.810488511 +0100
+@@ -29,7 +29,7 @@
+ import org.pentaho.reporting.libraries.formula.util.NumberUtil;
+
+ /**
+- * This function extracts the minute (0 through 59) from a time.
++ * This function extracts the seconds (0 through 59) from a time.
+ *
+ * @author Cedric Pronzato
+ */
+@@ -67,14 +67,15 @@
+
+ // time * 24 so that we get the full hours (which we remove later)
+ final BigDecimal bd = NumberUtil.getAsBigDecimal(n);
+- final BigDecimal hours = bd.multiply(MINUTES_PER_DAY);
+- final BigDecimal dayAndHoursAsInt = NumberUtil.performIntRounding(hours);
+- final BigDecimal minutesFraction = hours.subtract(dayAndHoursAsInt);
+-
+- // Multiply the minutes with 60 to get the minutes as ints
+- final BigDecimal seconds = minutesFraction.multiply(SECONDS);
+- final BigDecimal secondsAsInt = NumberUtil.performIntRounding(seconds);
++ final BigDecimal minutes = bd.multiply(MINUTES_PER_DAY);
++ final BigDecimal dayHoursAndMinutesAsInt = NumberUtil.performIntRounding(minutes);
++ final BigDecimal secondsFraction = minutes.subtract(dayHoursAndMinutesAsInt);
++
++ // Multiply the minutes with 60 to get the seconds as ints
++ final BigDecimal seconds = secondsFraction.multiply(SECONDS);
++ final BigDecimal nanoSeconds = seconds.setScale(9, BigDecimal.ROUND_HALF_UP);
++ final BigDecimal secondsAsInt = NumberUtil.performIntRounding(nanoSeconds);
+
+ return new TypeValuePair(NumberType.GENERIC_NUMBER, secondsAsInt);
+ }
+-}
+\ No newline at end of file
++}