Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shal committed Feb 4, 2024
1 parent 5fb0286 commit e2f5977
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions pkg/portal/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,27 @@ type Operation struct {

// FixDate returns fixed date in string format.
func FixDate(lexeme string) string {
r := regexp.MustCompile(`^(\d{2})\.(\d{2})\.(\d{4})$`)
r2 := regexp.MustCompile(`^(\d{2})\.(\d{2})\.(\d{2})$`)
r4 := regexp.MustCompile(`^(\d{2})\.(\d{2})\.(\d{4})$`)

if !r.MatchString(lexeme) {
return lexeme
if r2.MatchString(lexeme) {
date := r2.ReplaceAllString(lexeme, "$1")
month := r2.ReplaceAllString(lexeme, "$2")
year := r2.ReplaceAllString(lexeme, "$3")

return fmt.Sprintf("%s-%s-%s", year, month, "20"+date)
}

if r4.MatchString(lexeme) {
date := r2.ReplaceAllString(lexeme, "$1")
month := r2.ReplaceAllString(lexeme, "$2")
year := r2.ReplaceAllString(lexeme, "$3")

return fmt.Sprintf("%s-%s-%s", year, month, date)
}

date := r.ReplaceAllString(lexeme, "$1")
month := r.ReplaceAllString(lexeme, "$2")
year := r.ReplaceAllString(lexeme, "$3")
return lexeme

Check failure on line 60 in pkg/portal/operation.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary trailing newline (whitespace)
return fmt.Sprintf("%s-%s-%s", year, month, date)
}

// FixBrandModel returns fixed brand.
Expand Down

0 comments on commit e2f5977

Please sign in to comment.