Skip to content

Commit bea1a03

Browse files
committed
Fix timestampz parsing
1 parent bde04ca commit bea1a03

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

listener/wal_transaction.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ func (c *Column) AssertValue(src []byte) {
7979

8080
strSrc := string(src)
8181

82-
const timestampLayout = "2006-01-02 15:04:05"
82+
const (
83+
timestampLayout = "2006-01-02 15:04:05"
84+
timestampWithTZLayout = "2006-01-02 15:04:05.999999999+00"
85+
)
8386

8487
switch c.valueType {
8588
case BoolOID:
@@ -93,7 +96,7 @@ func (c *Column) AssertValue(src []byte) {
9396
case TimestampOID:
9497
val, err = time.Parse(timestampLayout, strSrc)
9598
case TimestamptzOID:
96-
val, err = time.Parse(time.RFC3339, strSrc)
99+
val, err = time.ParseInLocation(timestampWithTZLayout, strSrc, time.UTC)
97100
case DateOID, TimeOID:
98101
val = strSrc
99102
case UUIDOID:

listener/wal_transaction_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,11 @@ func TestColumn_AssertValue(t *testing.T) {
236236
isKey: false,
237237
},
238238
args: args{
239-
src: []byte("2022-08-27T17:44:01.041007Z"),
239+
src: []byte("2022-08-27 17:44:58.083316+00"),
240240
},
241241
want: &Column{
242242
name: "created",
243-
value: time.Date(2022, 8, 27, 17, 44, 1, 41007000, time.UTC),
243+
value: time.Date(2022, 8, 27, 17, 44, 58, 83316000, time.UTC),
244244
valueType: 1184,
245245
isKey: false,
246246
},

0 commit comments

Comments
 (0)