aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2021-01-01 23:20:02 +0000
committerAndreas Beeker <kiwiwings@apache.org>2021-01-01 23:20:02 +0000
commitdc72c1a009a3402bb99d21e827fb3ab3a0d8a0d0 (patch)
treee39fc031f368a8321f4b911b8f0e14d999c8dc33 /src
parent8347bb64ac06f8aeb7711d106e663a5a2587cc0d (diff)
downloadpoi-dc72c1a009a3402bb99d21e827fb3ab3a0d8a0d0.tar.gz
poi-dc72c1a009a3402bb99d21e827fb3ab3a0d8a0d0.zip
fix year agnostic date/test values
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1885021 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/testcases/org/apache/poi/ss/formula/functions/TestDateValue.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestDateValue.java b/src/testcases/org/apache/poi/ss/formula/functions/TestDateValue.java
index 05da127bd9..055e997650 100644
--- a/src/testcases/org/apache/poi/ss/formula/functions/TestDateValue.java
+++ b/src/testcases/org/apache/poi/ss/formula/functions/TestDateValue.java
@@ -19,6 +19,10 @@ package org.apache.poi.ss.formula.functions;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import java.time.LocalDate;
+import java.time.Month;
+import java.time.Year;
+import java.time.temporal.ChronoUnit;
import java.util.Locale;
import org.apache.poi.ss.formula.eval.BlankEval;
@@ -52,14 +56,18 @@ public final class TestDateValue {
public void testDateValue() {
LocaleUtil.setUserLocale(Locale.ENGLISH);
try {
+ int days1900 = (int)ChronoUnit.DAYS.between(
+ LocalDate.of(1899, Month.DECEMBER, 31),
+ LocalDate.of(Year.now().getValue(), Month.FEBRUARY, 1)
+ )+1;
confirmDateValue(new StringEval("2020-02-01"), 43862);
confirmDateValue(new StringEval("01-02-2020"), 43862);
confirmDateValue(new StringEval("2020-FEB-01"), 43862);
confirmDateValue(new StringEval("2020-Feb-01"), 43862);
confirmDateValue(new StringEval("2020-FEBRUARY-01"), 43862);
- confirmDateValue(new StringEval("FEB-01"), 43862);
+ confirmDateValue(new StringEval("FEB-01"), days1900);
confirmDateValue(new StringEval("2/1/2020"), 43862);
- confirmDateValue(new StringEval("2/1"), 43862);
+ confirmDateValue(new StringEval("2/1"), days1900);
confirmDateValue(new StringEval("2020/2/1"), 43862);
confirmDateValue(new StringEval("2020/FEB/1"), 43862);
confirmDateValue(new StringEval("FEB/1/2020"), 43862);