remind: Don't preserve seconds if not specified

This commit is contained in:
Hamcha 2017-05-04 17:16:23 +02:00
parent a9acbe719e
commit 62106504ee

View file

@ -154,7 +154,7 @@ func parseDuration(date string) (time.Time, error) {
switch { switch {
case isSscanfValid(fmt.Sscanf(date, "%d/%d/%d-%d:%d:%d", &day, &month, &year, &hour, &min, &sec)): case isSscanfValid(fmt.Sscanf(date, "%d/%d/%d-%d:%d:%d", &day, &month, &year, &hour, &min, &sec)):
case isSscanfValid(fmt.Sscanf(date, "%d/%d/%d-%d:%d", &day, &month, &year, &hour, &min)): case isSscanfValid(fmt.Sscanf(date, "%d/%d/%d-%d:%d", &day, &month, &year, &hour, &min)):
sec = now.Second() sec = 0
case isSscanfValid(fmt.Sscanf(date, "%d/%d/%d", &day, &month, &year)): case isSscanfValid(fmt.Sscanf(date, "%d/%d/%d", &day, &month, &year)):
hour = now.Hour() hour = now.Hour()
min = now.Minute() min = now.Minute()
@ -167,7 +167,7 @@ func parseDuration(date string) (time.Time, error) {
day = now.Day() day = now.Day()
month = now.Month() month = now.Month()
year = now.Year() year = now.Year()
sec = now.Second() sec = 0
case isSscanfValid(fmt.Sscanf(date, "%d%c", &num, &sep)): case isSscanfValid(fmt.Sscanf(date, "%d%c", &num, &sep)):
dur := time.Duration(num) dur := time.Duration(num)
switch unicode.ToLower(sep) { switch unicode.ToLower(sep) {