From 6958d6d3dcd3d0d8a39815c625edf543f1ccdad8 Mon Sep 17 00:00:00 2001 From: Nash Tsai Date: Tue, 19 Aug 2014 10:38:57 +0800 Subject: [PATCH] guard uninitialized time in func (engine *Engine) TZTime(t time.Time) --- engine.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/engine.go b/engine.go index bf041410..85eb488f 100644 --- a/engine.go +++ b/engine.go @@ -1396,8 +1396,16 @@ func (engine *Engine) Import(r io.Reader) ([]sql.Result, error) { return results, lastError } +var ( + NULL_TIME time.Time +) + func (engine *Engine) TZTime(t time.Time) time.Time { - return t.In(engine.TZLocation) + + if NULL_TIME != t { // if time is not initialized it's not suitable for Time.In() + return t.In(engine.TZLocation) + } + return t } func (engine *Engine) NowTime(sqlTypeName string) interface{} {