Skip to content

Commit

Permalink
Fix timestamp parsing defect #135 (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelWe committed May 25, 2023
1 parent f13d7b5 commit f9a7bdc
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,13 +512,23 @@ func (v *connection) initializeSession() error {
return fmt.Errorf("can't get server timezone: %s", str)
}

v.serverTZOffset = str[len(str)-3:]
v.serverTZOffset = getTimeZoneOffset(str)

connectionLogger.Debug("Setting server timezone offset to %s", str[len(str)-3:])
connectionLogger.Debug("Setting server timezone offset to %s", v.serverTZOffset)

return nil
}

func getTimeZoneOffset(str string) string {
for i := len(str) - 1; i >= 0 && i >= len(str)-8; i-- {
ch := str[i]
if ch == '+' || ch == '-' {
return str[i:]
}
}
return "+00"
}

func (v *connection) defaultMessageHandler(bMsg msgs.BackEndMsg) (bool, error) {

handled := true
Expand Down

0 comments on commit f9a7bdc

Please sign in to comment.