@@ -316,7 +316,7 @@ func QValueFromMysqlFieldValue(qkind types.QValueKind, mytype byte, fv mysql.Fie
316
316
if strings .HasPrefix (unsafeString , "0000-00-00" ) {
317
317
return types.QValueTimestamp {Val : time .Unix (0 , 0 )}, nil
318
318
}
319
- val , err := time .Parse ("2006-01-02 15:04:05.999999" , unsafeString )
319
+ val , err := time .Parse ("2006-01-02 15:04:05.999999" , strings . ReplaceAll ( unsafeString , "-00" , "-01" ) )
320
320
if err != nil {
321
321
return nil , err
322
322
}
@@ -334,7 +334,7 @@ func QValueFromMysqlFieldValue(qkind types.QValueKind, mytype byte, fv mysql.Fie
334
334
if unsafeString == "0000-00-00" {
335
335
return types.QValueDate {Val : time .Unix (0 , 0 )}, nil
336
336
}
337
- val , err := time .Parse (time .DateOnly , unsafeString )
337
+ val , err := time .Parse (time .DateOnly , strings . ReplaceAll ( unsafeString , "-00" , "-01" ) )
338
338
if err != nil {
339
339
return nil , err
340
340
}
@@ -469,13 +469,13 @@ func QValueFromMysqlRowEvent(
469
469
return types.QValueTime {Val : tm }, nil
470
470
case types .QValueKindDate :
471
471
if val == "0000-00-00" {
472
- return types.QValueDate {Val : time .Unix (0 , 0 )}, nil
472
+ return types.QValueDate {Val : time .Unix (0 , 0 ). UTC () }, nil
473
473
}
474
- val , err := time .Parse (time .DateOnly , val )
474
+ val , err := time .Parse (time .DateOnly , strings . ReplaceAll ( val , "-00" , "-01" ) )
475
475
if err != nil {
476
476
return nil , err
477
477
}
478
- return types.QValueDate {Val : val }, nil
478
+ return types.QValueDate {Val : val . UTC () }, nil
479
479
case types .QValueKindTimestamp : // 0000-00-00 ends up here
480
480
if mytype == mysql .MYSQL_TYPE_TIME || mytype == mysql .MYSQL_TYPE_TIME2 {
481
481
tm , err := processTime (val )
@@ -485,13 +485,13 @@ func QValueFromMysqlRowEvent(
485
485
return types.QValueTimestamp {Val : time .Unix (0 , 0 ).UTC ().Add (tm )}, nil
486
486
}
487
487
if strings .HasPrefix (val , "0000-00-00" ) {
488
- return types.QValueTimestamp {Val : time .Unix (0 , 0 )}, nil
488
+ return types.QValueTimestamp {Val : time .Unix (0 , 0 ). UTC () }, nil
489
489
}
490
- tm , err := time .Parse ("2006-01-02 15:04:05.999999" , val )
490
+ tm , err := time .Parse ("2006-01-02 15:04:05.999999" , strings . ReplaceAll ( val , "-00" , "-01" ) )
491
491
if err != nil {
492
492
return nil , err
493
493
}
494
- return types.QValueTimestamp {Val : tm }, nil
494
+ return types.QValueTimestamp {Val : tm . UTC () }, nil
495
495
}
496
496
}
497
497
return nil , fmt .Errorf ("unexpected type %T for mysql type %d, qkind %s" , val , mytype , qkind )
0 commit comments