Signed-off-by: 商讯在线 <swhbox@foxmail.com>
This commit is contained in:
商讯在线 2014-04-16 20:08:53 +08:00
parent 1c100c7659
commit e8c0ff31b3
3 changed files with 9 additions and 9 deletions

View File

@ -1086,13 +1086,13 @@ func (engine *Engine) TZTime(t time.Time) (r time.Time) {
return return
} }
func (engine *Engine) NowTime(SQLTypeName string) interface{} { func (engine *Engine) NowTime(sqlTypeName string) interface{} {
t := time.Now() t := time.Now()
return engine.FormatTime(SQLTypeName, t) return engine.FormatTime(sqlTypeName, t)
} }
func (engine *Engine) FormatTime(SQLTypeName string, t time.Time) (v interface{}) { func (engine *Engine) FormatTime(sqlTypeName string, t time.Time) (v interface{}) {
switch SQLTypeName { switch sqlTypeName {
case Time: case Time:
s := engine.TZTime(t).Format("2006-01-02 15:04:05") //time.RFC3339 s := engine.TZTime(t).Format("2006-01-02 15:04:05") //time.RFC3339
v = s[11:19] v = s[11:19]

View File

@ -1964,7 +1964,7 @@ func (session *Session) byte2Time(col *Column, data []byte) (outTime time.Time,
outErr = errors.New(fmt.Sprintf("unsupported time format %v: %v", sdata, err)) outErr = errors.New(fmt.Sprintf("unsupported time format %v: %v", sdata, err))
return return
} }
outTime = x outTime = session.Engine.TZTime(x)
return return
} }

View File

@ -24,7 +24,7 @@ func NewEngine(driverName string, dataSourceName string) (*Engine, error) {
DriverName: driverName, DriverName: driverName,
DataSourceName: dataSourceName, DataSourceName: dataSourceName,
Filters: make([]Filter, 0), Filters: make([]Filter, 0),
TimeZone: "UTC", TimeZone: "Local",
} }
engine.SetMapper(SnakeMapper{}) engine.SetMapper(SnakeMapper{})