fix TestTagTime
This commit is contained in:
parent
a6b31d79d7
commit
50ef83d456
|
@ -69,6 +69,13 @@ func String2Time(s string, originalLocation *time.Location, convertedLocation *t
|
|||
}
|
||||
dt = dt.In(convertedLocation)
|
||||
return &dt, nil
|
||||
} else if len(s) == 21 && s[10] == 'T' {
|
||||
dt, err := time.ParseInLocation("2006-01-02T15:04:05", s[:19], originalLocation)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dt = dt.In(convertedLocation)
|
||||
return &dt, nil
|
||||
} else if len(s) == 10 && s[4] == '-' {
|
||||
if s == "0000-00-00" || s == "0001-01-01" {
|
||||
return &time.Time{}, nil
|
||||
|
|
|
@ -6,12 +6,11 @@ package integrations
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"xorm.io/xorm/convert"
|
||||
"xorm.io/xorm/internal/utils"
|
||||
"xorm.io/xorm/names"
|
||||
"xorm.io/xorm/schemas"
|
||||
|
@ -1201,8 +1200,10 @@ func TestTagTime(t *testing.T) {
|
|||
has, err = testEngine.Table("tag_u_t_c_struct").Cols("created").Get(&tm)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, has)
|
||||
assert.EqualValues(t, s.Created.UTC().Format("2006-01-02 15:04:05"),
|
||||
strings.ReplaceAll(strings.ReplaceAll(tm, "T", " "), "Z", ""))
|
||||
|
||||
tmTime, err := convert.String2Time(tm, time.UTC, time.UTC)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, s.Created.UTC().Format("2006-01-02 15:04:05"), tmTime.Format("2006-01-02 15:04:05"))
|
||||
}
|
||||
|
||||
func TestTagAutoIncr(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue