You've already forked VptPassiveAdapter
Initial
This commit is contained in:
16
util/parse_date.go
Normal file
16
util/parse_date.go
Normal file
@ -0,0 +1,16 @@
|
||||
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]))
|
||||
}
|
Reference in New Issue
Block a user