]> Cypherpunks repositories - gostls13.git/commitdiff
encoding/asn1: don't convert UTCTime to UTC.
authorAdam Langley <agl@golang.org>
Mon, 29 Oct 2012 15:16:05 +0000 (11:16 -0400)
committerAdam Langley <agl@golang.org>
Mon, 29 Oct 2012 15:16:05 +0000 (11:16 -0400)
Previously we converted a time to UTC *and* serialized the timezone of
the original time. With this change, we serialize a UTCTime in the
original timezone.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6817048

src/pkg/encoding/asn1/marshal.go
src/pkg/encoding/asn1/marshal_test.go

index 3fd6be8ad92627391dd110a5538f56a2c6798db0..0c216fdb3cd8947120587ed6b8454dac066f9dde 100644 (file)
@@ -296,8 +296,7 @@ func marshalTwoDigits(out *forkableWriter, v int) (err error) {
 }
 
 func marshalUTCTime(out *forkableWriter, t time.Time) (err error) {
-       utc := t.UTC()
-       year, month, day := utc.Date()
+       year, month, day := t.Date()
 
        switch {
        case 1950 <= year && year < 2000:
@@ -321,7 +320,7 @@ func marshalUTCTime(out *forkableWriter, t time.Time) (err error) {
                return
        }
 
-       hour, min, sec := utc.Clock()
+       hour, min, sec := t.Clock()
 
        err = marshalTwoDigits(out, hour)
        if err != nil {
index c203533a91761c9a9c9c86ebc889b093d71b9ae4..55d34a709a486d239477722a1b97c421542138dd 100644 (file)
@@ -82,7 +82,7 @@ var marshalTests = []marshalTest{
        {explicitTagTest{64}, "3005a503020140"},
        {time.Unix(0, 0).UTC(), "170d3730303130313030303030305a"},
        {time.Unix(1258325776, 0).UTC(), "170d3039313131353232353631365a"},
-       {time.Unix(1258325776, 0).In(PST), "17113039313131353232353631362d30383030"},
+       {time.Unix(1258325776, 0).In(PST), "17113039313131353134353631362d30383030"},
        {BitString{[]byte{0x80}, 1}, "03020780"},
        {BitString{[]byte{0x81, 0xf0}, 12}, "03030481f0"},
        {ObjectIdentifier([]int{1, 2, 3, 4}), "06032a0304"},