mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-06 02:36:49 +00:00
improve date parsing
This commit is contained in:
parent
b25d7be29d
commit
18daf5d482
1 changed files with 2 additions and 2 deletions
|
|
@ -261,7 +261,7 @@ func (bs Service) ParseFromApi(rawContent string) (*Booking, error) {
|
|||
}
|
||||
|
||||
func extractDate(pattern, content string) string {
|
||||
re := regexp.MustCompile(pattern + `\w+\.\s*\d{1,2}\s\w+\.*\s\d{4}`)
|
||||
re := regexp.MustCompile(pattern + `(lun|mar|mer|jeu|ven|sam|dim)\. \d{1,2} (janv|févr|mars|avr|mai|juin|juil|août|sept|oct|nov|déc)\.? \d{4}`)
|
||||
dateMatch := re.FindString(content)
|
||||
|
||||
if dateMatch == "" {
|
||||
|
|
@ -311,7 +311,7 @@ func extractString(pattern, content string) string {
|
|||
func formatDate(date string) *time.Time {
|
||||
months := map[string]string{
|
||||
"janv.": "01", "fév": "02", "mar": "03", "avr": "04",
|
||||
"mai": "05", "juin": "06", "juil.": "07", "aoû": "08",
|
||||
"mai": "05", "juin": "06", "juil.": "07", "août": "08",
|
||||
"sep": "09", "oct": "10", "nov": "11", "déc": "12",
|
||||
}
|
||||
parts := strings.Split(date, " ")
|
||||
|
|
|
|||
Loading…
Reference in a new issue