You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/08/06 18:19:49 UTC
svn commit: r1892047 -
/poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/functions/TimeValue.java
Author: fanningpj
Date: Fri Aug 6 18:19:49 2021
New Revision: 1892047
URL: http://svn.apache.org/viewvc?rev=1892047&view=rev
Log:
add basic implementation of TIMEVALUE function
Modified:
poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/functions/TimeValue.java
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/functions/TimeValue.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/functions/TimeValue.java?rev=1892047&r1=1892046&r2=1892047&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/functions/TimeValue.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/functions/TimeValue.java Fri Aug 6 18:19:49 2021
@@ -25,7 +25,6 @@ import org.apache.poi.ss.util.DateParser
import java.time.DateTimeException;
import java.time.LocalDate;
-import java.util.Date;
/**
* Implementation for the TIMEVALUE() Excel function.<p>
@@ -59,10 +58,12 @@ public class TimeValue extends Fixed1Arg
}
try {
- return parseTime(dateTimeText);
+ return parseTimeFromDateTime(dateTimeText);
} catch (Exception e) {
try {
- return parseTime("1/01/2000 " + dateTimeText);
+ //this could be a time (with no date part) - prepend a dummy date because
+ //parseTimeFromDateTime needs it
+ return parseTimeFromDateTime("1/01/2000 " + dateTimeText);
} catch (Exception e2) {
LocalDate ld = DateParser.parseLocalDate(dateTimeText);
//return 0 as this is a pure date with no time element
@@ -77,7 +78,7 @@ public class TimeValue extends Fixed1Arg
}
}
- private NumberEval parseTime(String dateTimeText) throws EvaluationException {
+ private NumberEval parseTimeFromDateTime(String dateTimeText) throws EvaluationException {
double dateTimeValue = DateUtil.parseDateTime(dateTimeText);
return new NumberEval(dateTimeValue - DateUtil.getExcelDate(DateParser.parseLocalDate(dateTimeText)));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org