Skip to content

Commit

Permalink
fix timezone offset show bug (#24)
Browse files Browse the repository at this point in the history
* fix ZoneOffset show in time formating

---------

Co-authored-by: ali <[email protected]>
  • Loading branch information
aliworkshop and aliworkshop authored May 15, 2023
1 parent 5912edd commit 383c792
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions ptime.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,21 +809,16 @@ func (t Time) ZoneOffset(f ...string) string {
}
}

sign := "+"
if offset < 0 {
sign = "-"
}

h := offset / 3600
m := (offset - h*3600) / 60

switch format {
case "-0700", "Z0700":
return fmt.Sprintf("%s%02d%02d", sign, h, m)
return fmt.Sprintf("%+03d%02d", h, m)
case "-07":
return fmt.Sprintf("%s%02d", sign, h)
return fmt.Sprintf("%+03d", h)
default:
return fmt.Sprintf("%s%02d:%02d", sign, h, m)
return fmt.Sprintf("%+03d:%02d", h, m)
}
}

Expand Down

0 comments on commit 383c792

Please sign in to comment.