mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-06 02:36:49 +00:00
better date formatting
This commit is contained in:
parent
6bff5ccc18
commit
ee3674e12f
2 changed files with 7 additions and 3 deletions
|
|
@ -51,7 +51,10 @@ func (bs Service) Create(From time.Time, To time.Time, Name string, PhoneNumber
|
|||
PlatformFees: PlatformFees,
|
||||
ExternalId: externalId,
|
||||
}
|
||||
_ = bs.db.Create(b)
|
||||
err := bs.db.Create(b)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +251,6 @@ func (bs Service) ParseFromApi(rawContent string) (*Booking, error) {
|
|||
item := extractString(`Maison 1 Chambre \((T2|T3) -`, content)
|
||||
externalId := extractString(`Numéro de réservation : \n\s+(\d+)`, content)
|
||||
standardRate := extractFloat(`Standard Rate\n\s+€ (\d+)`, content)
|
||||
|
||||
taxQty := (totalAmount - standardRate*float64(stayLength)) / 1.5
|
||||
|
||||
b := bs.Create(*formatDate(arrivalDate), *formatDate(departureDate), customerName, "", customerEmail, "Booking", customerNumber, commissionAmount, externalId)
|
||||
|
|
@ -313,10 +315,11 @@ func formatDate(date string) *time.Time {
|
|||
"sep": "09", "oct": "10", "nov": "11", "déc": "12",
|
||||
}
|
||||
parts := strings.Split(date, " ")
|
||||
dateString := fmt.Sprintf("%s-%s-%s", parts[2], months[parts[1]], parts[0])
|
||||
dateString := fmt.Sprintf("%s-%02s-%02s", parts[2], months[parts[1]], parts[0])
|
||||
|
||||
t, err := time.Parse(time.DateOnly, dateString)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return nil
|
||||
}
|
||||
return &t
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import (
|
|||
|
||||
func handleSync(bs *booking.Service) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
log.Info("received booking sync request from booking")
|
||||
x := c.Request().Body
|
||||
body, err := io.ReadAll(x)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue