summaryrefslogtreecommitdiff
path: root/date.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2020-03-04 00:07:13 +0800
committerGitHub <noreply@github.com>2020-03-04 00:07:13 +0800
commitcb797540684d82fdb0fab111d0efce2977b24bf3 (patch)
tree8c96d852ebe67c39e7145d5129c793e83afc4db8 /date.go
parent1e3c85024d3bbc650c2f6a85fb075804af74720b (diff)
parent83eedce70de7a1ddeb3a4446f86b13bc6ff0b5ec (diff)
Merge pull request #592 from hexbioc/master
Exported function to convert excel date to time
Diffstat (limited to 'date.go')
-rw-r--r--date.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/date.go b/date.go
index dad39b5..172c32c 100644
--- a/date.go
+++ b/date.go
@@ -172,3 +172,11 @@ func timeFromExcelTime(excelTime float64, date1904 bool) time.Time {
durationPart := time.Duration(dayNanoSeconds * floatPart)
return date.Add(durationDays).Add(durationPart)
}
+
+// ExcelDateToTime converts a float-based excel date representation to a time.Time.
+func ExcelDateToTime(excelDate float64, use1904Format bool) (time.Time, error) {
+ if excelDate < 0 {
+ return time.Time{}, newInvalidExcelDateError(excelDate)
+ }
+ return timeFromExcelTime(excelDate, use1904Format), nil
+}