Skip to content

Commit

Permalink
Merge pull request #270 from actiontech/periods-unit-test
Browse files Browse the repository at this point in the history
add unit test for periods
  • Loading branch information
sjjian authored Jun 19, 2024
2 parents e30625d + 0151220 commit e1bd3f7
Show file tree
Hide file tree
Showing 2 changed files with 472 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/periods/periods.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ type Period struct {
}

// ParsePeriods parse string in importing db services csv column like: 09:30-11:30;11:30-13:30;20:30-21:30 to *Periods
// todo unit test
func ParsePeriods(s string) (Periods, error) {
start2ends := strings.Split(s, ";")
ps := make(Periods, len(start2ends))
for k, v := range start2ends {
p := Period{}
// if sth follows "%d:%d-%d:%d", it will be ignored
_, err := fmt.Sscanf(v, "%d:%d-%d:%d", &p.StartHour, &p.StartMinute, &p.EndHour, &p.EndMinute)
if err != nil {
return nil, err
Expand Down
Loading

0 comments on commit e1bd3f7

Please sign in to comment.