parse timestamp with milliseconds in tz format #2246

Merged
lunny merged 3 commits from agarcia/xorm:fix-parse-timestamp-milliseconds-TZ-format into master 2023-04-06 13:48:00 +00:00
Contributor

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

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](https://gitea.com/xorm/xorm/issues/2244)
agarcia added 2 commits 2023-04-06 10:24:20 +00:00
agarcia changed title from fix-parse-timestamp-milliseconds-TZ-format to fix: parse timestamp with milliseconds in tz format 2023-04-06 10:26:17 +00:00
agarcia changed title from fix: parse timestamp with milliseconds in tz format to WIP: parse timestamp with milliseconds in tz format 2023-04-06 10:40:18 +00:00
agarcia added 1 commit 2023-04-06 10:54:56 +00:00
check pipeline
All checks were successful
continuous-integration/drone/pr Build is passing
5ab6301037
agarcia changed title from WIP: parse timestamp with milliseconds in tz format to parse timestamp with milliseconds in tz format 2023-04-06 11:32:32 +00:00
agarcia requested review from lunny 2023-04-06 11:46:40 +00:00
lunny added the
kind
bug
label 2023-04-06 12:00:23 +00:00
lunny approved these changes 2023-04-06 12:01:16 +00:00
lunny merged commit 94fcec7f65 into master 2023-04-06 13:48:00 +00:00
Sign in to join this conversation.
No description provided.