parent
9f8bce0361
commit
d269b45582
@ -0,0 +1,16 @@
|
|||||||
|
package gotime
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
// Verification 验证字符串是否为时间
|
||||||
|
func Verification(str, layout string) (resp time.Time, err error) {
|
||||||
|
loc, err := time.LoadLocation("Asia/Shanghai")
|
||||||
|
if err != nil {
|
||||||
|
return time.Time{}, err
|
||||||
|
}
|
||||||
|
location, err := time.ParseInLocation(layout, str, loc)
|
||||||
|
if err != nil {
|
||||||
|
return time.Time{}, err
|
||||||
|
}
|
||||||
|
return location, nil
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package gotime
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestVerification(t *testing.T) {
|
||||||
|
t.Log(Verification("2022-02-05 00:00:00", DateTimeFormat))
|
||||||
|
}
|
@ -1,3 +1,3 @@
|
|||||||
package gotime
|
package gotime
|
||||||
|
|
||||||
const Version = "1.0.4"
|
const Version = "1.0.5"
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package gotime
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestVersion(t *testing.T) {
|
||||||
|
t.Log(Version)
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkVersion(b *testing.B) {
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
b.Log(Version)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue