mirror of https://github.com/go-gitea/gitea
Update models/issues/issue.go
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
This commit is contained in:
parent
deddce59cf
commit
fb8126035a
|
@ -2535,17 +2535,19 @@ func (issue *Issue) HasOriginalAuthor() bool {
|
|||
return issue.OriginalAuthor != "" && issue.OriginalAuthorID != 0
|
||||
}
|
||||
|
||||
var (
|
||||
// Time match regex
|
||||
rOnlyHours = regexp.MustCompile(`^([\d]+)$`)
|
||||
rWeeks = regexp.MustCompile(`([\d]+)w`)
|
||||
rDays = regexp.MustCompile(`([\d]+)d`)
|
||||
rHours = regexp.MustCompile(`([\d]+)h`)
|
||||
rMinutes = regexp.MustCompile(`([\d]+)m`)
|
||||
)
|
||||
|
||||
// TimeEstimateFromStr returns time estimate in seconds from formatted string
|
||||
func (issue *Issue) TimeEstimateFromStr(timeStr string) int64 {
|
||||
timeTotal := 0
|
||||
|
||||
// Time match regex
|
||||
rOnlyHours := regexp.MustCompile(`^([\d]+)$`)
|
||||
rWeeks := regexp.MustCompile(`([\d]+)w`)
|
||||
rDays := regexp.MustCompile(`([\d]+)d`)
|
||||
rHours := regexp.MustCompile(`([\d]+)h`)
|
||||
rMinutes := regexp.MustCompile(`([\d]+)m`)
|
||||
|
||||
// If single number entered, assume hours
|
||||
timeStrMatches := rOnlyHours.FindStringSubmatch(timeStr)
|
||||
if len(timeStrMatches) > 0 {
|
||||
|
|
Loading…
Reference in New Issue