You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
688 B

  1. package testfixtures
  2. import "regexp"
  3. var (
  4. regexpDate = regexp.MustCompile("\\d\\d\\d\\d-\\d\\d-\\d\\d")
  5. regexpDateTime = regexp.MustCompile("\\d\\d\\d\\d-\\d\\d-\\d\\d \\d\\d:\\d\\d:\\d\\d")
  6. regexpTime = regexp.MustCompile("\\d\\d:\\d\\d:\\d\\d")
  7. )
  8. func isDate(value interface{}) bool {
  9. str, isStr := value.(string)
  10. if !isStr {
  11. return false
  12. }
  13. return regexpDate.MatchString(str)
  14. }
  15. func isDateTime(value interface{}) bool {
  16. str, isStr := value.(string)
  17. if !isStr {
  18. return false
  19. }
  20. return regexpDateTime.MatchString(str)
  21. }
  22. func isTime(value interface{}) bool {
  23. str, isStr := value.(string)
  24. if !isStr {
  25. return false
  26. }
  27. return regexpTime.MatchString(str)
  28. }