Skip to content

Commit

Permalink
Fix offset parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Jana Gierloff committed Jan 5, 2022
1 parent 2a80075 commit f43327d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config/config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ regex:
jirasorting: "(?i:<sort:)([a-zA-Z]*)(>)"
jirastatus: "(?i:<status:)([a-zA-Z]*)(>)"
jiratime: "(?i:<time:)([0-9]*[mhdw])(>)"
jiraoffsettime: "(?i:<offset-time:)([0-9]*[mhdw])(>)"
jiraoffsettime: "(?i:<offset-time:)([0-9]+[mhdw])(>)"
jiraoffsetfield: "(?i:<offset-field:)([a-zA-Z ]*)(>)"
replycolor: "(?i:<color:)([a-zA-Z0-9]*)(>)"
replylayout: "(?i:<layout:)([a-zA-Z0-9]*)(>)"
Expand Down
10 changes: 7 additions & 3 deletions utils/jira_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ func getStatus(statuses map[string]string, input string) string {
}

func addTime(startTime time.Time, offset string) time.Time {
timeMinutes := regexp.MustCompile(`^[0-9]*m$`)
timeHours := regexp.MustCompile(`^[0-9]*h$`)
timeDays := regexp.MustCompile(`^[0-9]*d$`)
timeMinutes := regexp.MustCompile(`^[0-9]+m$`)
timeHours := regexp.MustCompile(`^[0-9]+h$`)
timeDays := regexp.MustCompile(`^[0-9]+d$`)
timeWeeks := regexp.MustCompile(`^[0-9]+w$`)

returnTime := startTime

Expand All @@ -162,6 +163,9 @@ func addTime(startTime time.Time, offset string) time.Time {
case timeDays.MatchString(offset):
timeOffset, _ := strconv.Atoi(strings.ReplaceAll(offset, "d", ""))
returnTime = startTime.Add(time.Hour * 24 * time.Duration(timeOffset))
case timeWeeks.MatchString(offset):
timeOffset, _ := strconv.Atoi(strings.ReplaceAll(offset, "w", ""))
returnTime = startTime.Add(time.Hour * 24 * 7 * time.Duration(timeOffset))
}

return returnTime
Expand Down

0 comments on commit f43327d

Please sign in to comment.