mirror of
https://github.com/duke-git/lancet.git
synced 2026-11-16 05:12:11 +08:00
fix(package): [datetime] reject non-positive intervals (#386)
This commit is contained in:
1 parent
f1db13387b
commit
5c04ffae97
2 files changed
+20
No files matched your search
@@ -495,6 +495,9 @@ func GenerateDatetimesBetween(start, end time.Time, layout string, interval stri
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if duration <= 0 {
|
||||
return nil, fmt.Errorf("interval must be positive")
|
||||
}
|
||||
|
||||
for current := start; !current.After(end); current = current.Add(duration) {
|
||||
result = append(result, current.Format(layout))
|
||||
|
||||
Reference in new issue
Block a user