From 83eedce70de7a1ddeb3a4446f86b13bc6ff0b5ec Mon Sep 17 00:00:00 2001 From: Vaibhav Nayak Date: Tue, 3 Mar 2020 17:01:02 +0530 Subject: Export ExcelDateToTime function to convert excel date to time Signed-off-by: Vaibhav Nayak --- date.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'date.go') 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 +} -- cgit v1.2.1