summaryrefslogtreecommitdiffstats
path: root/vendor/xorm.io/xorm/session_convert.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-01-05 14:28:51 +0800
committerGitHub <noreply@github.com>2021-01-05 14:28:51 +0800
commit126c9331d6d8789563fae5d5bac2196d63fee0e8 (patch)
tree304d5f1ce134bd75344a4e7e1a376d7a6dc9cfb1 /vendor/xorm.io/xorm/session_convert.go
parent8db0372a45082c8827bdee1b449f618b393c026d (diff)
downloadgitea-126c9331d6d8789563fae5d5bac2196d63fee0e8.tar.gz
gitea-126c9331d6d8789563fae5d5bac2196d63fee0e8.zip
upgrade xorm to v1.0.6 (#14246)
Diffstat (limited to 'vendor/xorm.io/xorm/session_convert.go')
-rw-r--r--vendor/xorm.io/xorm/session_convert.go24
1 files changed, 23 insertions, 1 deletions
diff --git a/vendor/xorm.io/xorm/session_convert.go b/vendor/xorm.io/xorm/session_convert.go
index a683994731..4a4dd8be00 100644
--- a/vendor/xorm.io/xorm/session_convert.go
+++ b/vendor/xorm.io/xorm/session_convert.go
@@ -168,7 +168,29 @@ func (session *Session) bytes2Value(col *schemas.Column, fieldValue *reflect.Val
} else if strings.EqualFold(sdata, "false") {
x = 0
} else {
- x, err = strconv.ParseInt(sdata, 10, 64)
+ if col.SQLType.Name == schemas.DateTime {
+ if len(sdata) == 20 {
+ t, err := time.Parse("2006-01-02T15:04:05Z", sdata)
+ if err != nil {
+ return fmt.Errorf("arg %v as int: %s", key, err.Error())
+ }
+ x = t.Unix()
+ } else if len(sdata) == 19 {
+ var parseFormat = "2006-01-02 15:04:05"
+ if sdata[10] == 'T' {
+ parseFormat = "2006-01-02T15:04:05"
+ }
+ t, err := time.Parse(parseFormat, sdata)
+ if err != nil {
+ return fmt.Errorf("arg %v as int: %s", key, err.Error())
+ }
+ x = t.Unix()
+ } else {
+ x, err = strconv.ParseInt(sdata, 10, 64)
+ }
+ } else {
+ x, err = strconv.ParseInt(sdata, 10, 64)
+ }
}
if err != nil {
return fmt.Errorf("arg %v as int: %s", key, err.Error())