Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ohaibbq committed Jan 29, 2024
1 parent 704a5ae commit a6336fe
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/function_time_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -770,14 +770,18 @@ func minuteFormatter(t *time.Time) ([]rune, error) {
}

func parseDigitRespectingOptionalPlaces(text []rune, minNumber int64, maxNumber int64) (int, int64, error) {
// Given a target value of `minNumber` and `maxNumber`, parse the given text up to `maxNumber`'s places
// If a non-digit character is encountered, consider the digit parsed and move on
// e.g. ('3', 0, 99) == 3 ('03', 0, 99) == 3 ('04/', 0, 999) == 4

textLen := len(text)
places := len(fmt.Sprint(maxNumber))
var parts []string
if textLen == 0 {
return 0, 0, fmt.Errorf("empty text")
}

// Format tokens require at most `places` characters and at least 1 character
// Format tokens require at least 1 character most `places` characters
steps := places
if textLen < places {
steps = textLen
Expand Down

0 comments on commit a6336fe

Please sign in to comment.