Skip to content

Commit

Permalink
fix : time format
Browse files Browse the repository at this point in the history
  • Loading branch information
RawanMostafa08 committed Sep 20, 2024
1 parent c80cb76 commit 8202b0a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func HttpHandler(w http.ResponseWriter, r *http.Request) {
return
}
currentTime := time.Now()
formattedTime := currentTime.Format("2024/09/19 12:57:04")
formattedTime := currentTime.Format(time.ANSIC)

if strings.Contains(r.Header.Get("content-type"), "text/plain") {

Expand Down Expand Up @@ -54,7 +54,7 @@ func GinHandler(c *gin.Context) {
return
}
currentTime := time.Now()
formattedTime := currentTime.Format("2024/09/19 12:57:04")
formattedTime := currentTime.Format(time.ANSIC)

if strings.Contains(c.Request.Header.Get("content-type"), "text/plain") {
c.Writer.Header().Set("Content-Type", "text/plain")
Expand Down
4 changes: 2 additions & 2 deletions pkg/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestHttpHome(t *testing.T) {
}

func TestHttpHandler(t *testing.T) {
formattedTime := time.Now().Format("2024/09/19 12:57:04")
formattedTime := time.Now().Format(time.ANSIC)
timeJson, err := json.Marshal(formattedTime)
if err != nil {
t.Errorf("error converting to json: %v", err)
Expand Down Expand Up @@ -131,7 +131,7 @@ func TestGinHome(t *testing.T) {

func TestGinHandler(t *testing.T) {

formattedTime := time.Now().Format("2024/09/19 12:57:04")
formattedTime := time.Now().Format(time.ANSIC)
timeJson, err := json.Marshal(formattedTime)
if err != nil {
t.Errorf("error converting to json: %v", err)
Expand Down

0 comments on commit 8202b0a

Please sign in to comment.