diff --git a/bytesconv.go b/bytesconv.go index 216e0ea..3db9cdb 100644 --- a/bytesconv.go +++ b/bytesconv.go @@ -12,14 +12,6 @@ import ( "unsafe" ) -var gmtLocation = func() *time.Location { - x, err := time.LoadLocation("GMT") - if err != nil { - panic(fmt.Sprintf("cannot load GMT location: %s", err)) - } - return x -}() - // AppendIPv4 appends string representation of the given ip v4 to dst // and returns the extended dst. func AppendIPv4(dst []byte, ip net.IP) []byte { @@ -78,7 +70,9 @@ func ParseIPv4(dst net.IP, ipStr []byte) (net.IP, error) { // AppendHTTPDate appends HTTP-compliant (RFC1123) representation of date // to dst and returns the extended dst. func AppendHTTPDate(dst []byte, date time.Time) []byte { - return date.In(gmtLocation).AppendFormat(dst, time.RFC1123) + dst = date.In(time.UTC).AppendFormat(dst, time.RFC1123) + copy(dst[len(dst)-3:], strGMT) + return dst } // ParseHTTPDate parses HTTP-compliant (RFC1123) date. diff --git a/cookie.go b/cookie.go index bdd5170..29c3c05 100644 --- a/cookie.go +++ b/cookie.go @@ -218,7 +218,7 @@ func (c *Cookie) ParseBytes(src []byte) error { switch { case bytes.Equal(strCookieExpires, kv.key): v := unsafeBytesToStr(kv.value) - exptime, err := time.ParseInLocation(time.RFC1123, v, gmtLocation) + exptime, err := time.ParseInLocation(time.RFC1123, v, time.UTC) if err != nil { return err } diff --git a/fs.go b/fs.go index b428423..0ec4e81 100644 --- a/fs.go +++ b/fs.go @@ -938,7 +938,7 @@ func fsLastModified(path string) (time.Time, error) { } func fsModTime(t time.Time) time.Time { - return t.In(gmtLocation).Truncate(time.Second) + return t.In(time.UTC).Truncate(time.Second) } var ( diff --git a/strings.go b/strings.go index 5863f66..f696330 100644 --- a/strings.go +++ b/strings.go @@ -18,6 +18,7 @@ var ( strHTTP11 = []byte("HTTP/1.1") strColonSlashSlash = []byte("://") strColonSpace = []byte(": ") + strGMT = []byte("GMT") strResponseContinue = []byte("HTTP/1.1 100 Continue\r\n\r\n")