forgejo/vendor/gopkg.in/testfixtures.v2/time.go

37 lines
688 B
Go
Raw Normal View History

2016-12-29 10:03:40 +09:00
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)
}