This commit is contained in:
CyJaySong 2023-10-30 11:08:00 +08:00
parent 84c44e90cd
commit c09a9bdfc1
1 changed files with 2 additions and 5 deletions

View File

@ -85,12 +85,9 @@ func String2Time(s string, originalLocation *time.Location, convertedLocation *t
if err != nil { if err != nil {
return nil, err return nil, err
} }
currentDate := time.Now() dt = dt.AddDate(2006, 01, 02).In(convertedLocation)
// add current date for correct time locations
dt = dt.AddDate(currentDate.Year(), int(currentDate.Month()), currentDate.Day())
dt = dt.In(convertedLocation)
// back to zero year // back to zero year
dt = dt.AddDate(-currentDate.Year(), int(-currentDate.Month()), -currentDate.Day()) dt = dt.AddDate(-2006, -01, -02)
return &dt, nil return &dt, nil
} else { } else {
i, err := strconv.ParseInt(s, 10, 64) i, err := strconv.ParseInt(s, 10, 64)