mirror of
https://github.com/go-gitea/gitea
synced 2024-06-03 03:46:51 +02:00
Commit
This commit is contained in:
parent
fb8126035a
commit
bf323cf26c
|
@ -2536,12 +2536,12 @@ func (issue *Issue) HasOriginalAuthor() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Time match regex
|
// Time estimate match regex
|
||||||
rOnlyHours = regexp.MustCompile(`^([\d]+)$`)
|
rTimeEstimateOnlyHours = regexp.MustCompile(`^([\d]+)$`)
|
||||||
rWeeks = regexp.MustCompile(`([\d]+)w`)
|
rTimeEstimateWeeks = regexp.MustCompile(`([\d]+)w`)
|
||||||
rDays = regexp.MustCompile(`([\d]+)d`)
|
rTimeEstimateDays = regexp.MustCompile(`([\d]+)d`)
|
||||||
rHours = regexp.MustCompile(`([\d]+)h`)
|
rTimeEstimateHours = regexp.MustCompile(`([\d]+)h`)
|
||||||
rMinutes = regexp.MustCompile(`([\d]+)m`)
|
rTimeEstimateMinutes = regexp.MustCompile(`([\d]+)m`)
|
||||||
)
|
)
|
||||||
|
|
||||||
// TimeEstimateFromStr returns time estimate in seconds from formatted string
|
// TimeEstimateFromStr returns time estimate in seconds from formatted string
|
||||||
|
@ -2549,34 +2549,34 @@ func (issue *Issue) TimeEstimateFromStr(timeStr string) int64 {
|
||||||
timeTotal := 0
|
timeTotal := 0
|
||||||
|
|
||||||
// If single number entered, assume hours
|
// If single number entered, assume hours
|
||||||
timeStrMatches := rOnlyHours.FindStringSubmatch(timeStr)
|
timeStrMatches := rTimeEstimateOnlyHours.FindStringSubmatch(timeStr)
|
||||||
if len(timeStrMatches) > 0 {
|
if len(timeStrMatches) > 0 {
|
||||||
raw, _ := strconv.Atoi(timeStrMatches[1])
|
raw, _ := strconv.Atoi(timeStrMatches[1])
|
||||||
timeTotal += raw * (60 * 60)
|
timeTotal += raw * (60 * 60)
|
||||||
} else {
|
} else {
|
||||||
// Find time weeks
|
// Find time weeks
|
||||||
timeStrMatches = rWeeks.FindStringSubmatch(timeStr)
|
timeStrMatches = rTimeEstimateWeeks.FindStringSubmatch(timeStr)
|
||||||
if len(timeStrMatches) > 0 {
|
if len(timeStrMatches) > 0 {
|
||||||
raw, _ := strconv.Atoi(timeStrMatches[1])
|
raw, _ := strconv.Atoi(timeStrMatches[1])
|
||||||
timeTotal += raw * (60 * 60 * 24 * 7)
|
timeTotal += raw * (60 * 60 * 24 * 7)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find time days
|
// Find time days
|
||||||
timeStrMatches = rDays.FindStringSubmatch(timeStr)
|
timeStrMatches = rTimeEstimateDays.FindStringSubmatch(timeStr)
|
||||||
if len(timeStrMatches) > 0 {
|
if len(timeStrMatches) > 0 {
|
||||||
raw, _ := strconv.Atoi(timeStrMatches[1])
|
raw, _ := strconv.Atoi(timeStrMatches[1])
|
||||||
timeTotal += raw * (60 * 60 * 24)
|
timeTotal += raw * (60 * 60 * 24)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find time hours
|
// Find time hours
|
||||||
timeStrMatches = rHours.FindStringSubmatch(timeStr)
|
timeStrMatches = rTimeEstimateHours.FindStringSubmatch(timeStr)
|
||||||
if len(timeStrMatches) > 0 {
|
if len(timeStrMatches) > 0 {
|
||||||
raw, _ := strconv.Atoi(timeStrMatches[1])
|
raw, _ := strconv.Atoi(timeStrMatches[1])
|
||||||
timeTotal += raw * (60 * 60)
|
timeTotal += raw * (60 * 60)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find time minutes
|
// Find time minutes
|
||||||
timeStrMatches = rMinutes.FindStringSubmatch(timeStr)
|
timeStrMatches = rTimeEstimateMinutes.FindStringSubmatch(timeStr)
|
||||||
if len(timeStrMatches) > 0 {
|
if len(timeStrMatches) > 0 {
|
||||||
raw, _ := strconv.Atoi(timeStrMatches[1])
|
raw, _ := strconv.Atoi(timeStrMatches[1])
|
||||||
timeTotal += raw * (60)
|
timeTotal += raw * (60)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user