summaryrefslogtreecommitdiff
path: root/date.go
diff options
context:
space:
mode:
Diffstat (limited to 'date.go')
-rw-r--r--date.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/date.go b/date.go
index b49a695..172c32c 100644
--- a/date.go
+++ b/date.go
@@ -1,11 +1,11 @@
-// Copyright 2016 - 2019 The excelize Authors. All rights reserved. Use of
+// Copyright 2016 - 2020 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
// Package excelize providing a set of functions that allow you to write to
// and read from XLSX files. Support reads and writes XLSX file generated by
// Microsoft Excelâ„¢ 2007 and later. Support save file without losing original
-// charts of XLSX. This library needs Go version 1.8 or later.
+// charts of XLSX. This library needs Go version 1.10 or later.
package excelize
@@ -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
+}