Skip to content

Commit

Permalink
format time
Browse files Browse the repository at this point in the history
Signed-off-by: Ismael Ibuan <[email protected]>
  • Loading branch information
iibuan committed Sep 30, 2024
1 parent 480f3f6 commit e9f7f5f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
13 changes: 1 addition & 12 deletions src/goapp/controller/item/item-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"main/service"
"net/http"
"strconv"
"time"

"github.com/gorilla/mux"
)
Expand Down Expand Up @@ -224,21 +223,11 @@ func (c *itemController) postCallback(id string) {
fmt.Println("No callback url found")
return
} else {
// Parse the datetime string into a time.Time object
responseDate, err := time.Parse(time.RFC3339, item.DateResponded)
if err != nil {
fmt.Printf("invalid datetime format: %v", err)
return
}

// Format the time.Time object into a string that the database can recognize
formattedResponseDate := responseDate.Format("2006-01-02 15:04:05")

params := model.ResponseCallback{
ItemId: id,
IsApproved: item.IsApproved,
Remarks: item.ApproverRemarks,
ResponseDate: formattedResponseDate,
ResponseDate: item.DateResponded,
RespondedBy: item.RespondedBy,
}

Expand Down
2 changes: 1 addition & 1 deletion src/goapp/repository/item/item-repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (r *itemRepository) GetItemById(id string) (*model.Item, error) {
}

if result[0]["DateResponded"] != nil {
item.DateResponded = result[0]["DateResponded"].(time.Time).String()
item.DateResponded = result[0]["DateResponded"].(time.Time).Format("2006-01-02T15:04:05.000Z")
}

if result[0]["DateSent"] != nil {
Expand Down

0 comments on commit e9f7f5f

Please sign in to comment.