guard uninitialized time in func (engine *Engine) TZTime(t time.Time)

This commit is contained in:
Nash Tsai 2014-08-19 10:38:57 +08:00
parent 0e8dcc062b
commit 6958d6d3dc
1 changed files with 9 additions and 1 deletions

View File

@ -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{} {