package util import ( "fmt" "regexp" "time" ) func ParseDate(filePath string) (time.Time, error) { re := regexp.MustCompile(`(\d{4}).?(\d{2}).?(\d{2})`) matches := re.FindStringSubmatch(filePath) if len(matches) != 4 { return time.Time{}, fmt.Errorf("无法解析时间范围") } return time.Parse("2006.01.02", fmt.Sprintf("%s.%s.%s", matches[1], matches[2], matches[3])) }