From dc72c1a009a3402bb99d21e827fb3ab3a0d8a0d0 Mon Sep 17 00:00:00 2001 From: Andreas Beeker Date: Fri, 1 Jan 2021 23:20:02 +0000 Subject: fix year agnostic date/test values git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1885021 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/ss/formula/functions/TestDateValue.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/testcases/org/apache/poi') 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); -- cgit v1.2.3