1
0
forked from xorm/xorm
xorm/convert
Alberto Garcia 94fcec7f65 parse timestamp with milliseconds in tz format (#2246)
This pr fixes a bug caused when a timestmap in TZ format with milliseconds (`2023-04-05T15:50:48.256816Z` or `2023-04-05T15:50:48.256816+08:00`) is being parsed.

- The bug is happens in the function `String2Time` in `convert/time.go`
- if the timestamp contains milliseconds a layout with the structure `2006-01-02 15:04:05.` is used to parse it
- This layout contains an space between the date and the hour, if the timestamp returned by the db contains a `T` the parser fails and an error is returned

This pr adds a check for the `T` and milliseconds in the timestamp, if both conditions are present the date is parsed using the RFC3339 layout

Added test cases to check timestamps in this format

Solves [#2244](xorm/xorm#2244)

Reviewed-on: xorm/xorm#2246
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Alberto Garcia <agarcia@circutor.com>
Co-committed-by: Alberto Garcia <agarcia@circutor.com>
2023-04-06 21:47:59 +08:00
..
bool.go Move convert back to xorm.io/xorm/convert (#2030) 2021-08-10 23:20:53 +08:00
conversion.go Add dameng support (#2007) 2021-08-24 13:46:08 +08:00
float.go Move convert back to xorm.io/xorm/convert (#2030) 2021-08-10 23:20:53 +08:00
int.go Move convert back to xorm.io/xorm/convert (#2030) 2021-08-10 23:20:53 +08:00
interface.go Move convert back to xorm.io/xorm/convert (#2030) 2021-08-10 23:20:53 +08:00
scanner.go Move convert back to xorm.io/xorm/convert (#2030) 2021-08-10 23:20:53 +08:00
string.go Move convert back to xorm.io/xorm/convert (#2030) 2021-08-10 23:20:53 +08:00
time_test.go parse timestamp with milliseconds in tz format (#2246) 2023-04-06 21:47:59 +08:00
time.go parse timestamp with milliseconds in tz format (#2246) 2023-04-06 21:47:59 +08:00