mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-01 16:51:17 +03:00
37 lines
688 B
Go
37 lines
688 B
Go
|
package testfixtures
|
||
|
|
||
|
import "regexp"
|
||
|
|
||
|
var (
|
||
|
regexpDate = regexp.MustCompile("\\d\\d\\d\\d-\\d\\d-\\d\\d")
|
||
|
regexpDateTime = regexp.MustCompile("\\d\\d\\d\\d-\\d\\d-\\d\\d \\d\\d:\\d\\d:\\d\\d")
|
||
|
regexpTime = regexp.MustCompile("\\d\\d:\\d\\d:\\d\\d")
|
||
|
)
|
||
|
|
||
|
func isDate(value interface{}) bool {
|
||
|
str, isStr := value.(string)
|
||
|
if !isStr {
|
||
|
return false
|
||
|
}
|
||
|
|
||
|
return regexpDate.MatchString(str)
|
||
|
}
|
||
|
|
||
|
func isDateTime(value interface{}) bool {
|
||
|
str, isStr := value.(string)
|
||
|
if !isStr {
|
||
|
return false
|
||
|
}
|
||
|
|
||
|
return regexpDateTime.MatchString(str)
|
||
|
}
|
||
|
|
||
|
func isTime(value interface{}) bool {
|
||
|
str, isStr := value.(string)
|
||
|
if !isStr {
|
||
|
return false
|
||
|
}
|
||
|
|
||
|
return regexpTime.MatchString(str)
|
||
|
}
|