diff options
author | xuri <xuri.me@gmail.com> | 2019-03-23 20:08:06 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2019-03-23 20:08:06 +0800 |
commit | 40ff5dc1a7d7aa42f5db9cf9dfe858cc3820b44e (patch) | |
tree | 9683b0a18a08f6603065506589a3c86dba5b8bb1 /date.go | |
parent | 2874d75555102b8266477cdda2966ff37dde6b12 (diff) |
refactor: handler error instead of panic,
Exported functions:
SetCellStyle
InsertCol
RemoveCol
RemoveRow
InsertRow
DuplicateRow
DuplicateRowTo
SetRowHeight
GetRowHeight
GetCellValue
GetCellFormula
GetCellHyperLink
SetCellHyperLink
SetCellInt
SetCellBool
SetCellFloat
SetCellStr
SetCellDefault
GetCellStyle
SetCellValue
MergeCell
SetSheetRow
SetRowVisible
GetRowVisible
SetRowOutlineLevel
GetRowOutlineLevel
GetRows
Columns
SearchSheet
AddTable
GetPicture
AutoFilter
GetColVisible
SetColVisible
GetColOutlineLevel
SetColOutlineLevel
SetColWidth
GetColWidth
inner functions:
adjustHelper
adjustMergeCells
adjustAutoFilter
prepareCell
setDefaultTimeStyle
timeToExcelTime
addDrawingChart
addDrawingVML
addDrawingPicture
getTotalRowsCols
checkRow
addDrawingShape
addTable
Diffstat (limited to 'date.go')
-rw-r--r-- | date.go | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -10,6 +10,7 @@ package excelize import ( + "errors" "math" "time" ) @@ -25,18 +26,18 @@ var ( ) // timeToExcelTime provides a function to convert time to Excel time. -func timeToExcelTime(t time.Time) float64 { +func timeToExcelTime(t time.Time) (float64, error) { // TODO in future this should probably also handle date1904 and like TimeFromExcelTime // Force user to explicit convet passed value to UTC time. // Because for example 1900-01-01 00:00:00 +0300 MSK converts to 1900-01-01 00:00:00 +0230 LMT // probably due to daylight saving. if t.Location() != time.UTC { - panic("only UTC time expected") + return 0.0, errors.New("only UTC time expected") } if t.Before(excelMinTime1900) { - return 0.0 + return 0.0, nil } tt := t @@ -60,7 +61,7 @@ func timeToExcelTime(t time.Time) float64 { if t.After(excelBuggyPeriodStart) { result += 1.0 } - return result + return result, nil } // shiftJulianToNoon provides a function to process julian date to noon. |