Parse "Z" timezone suffix in datetime

Another gotcha is that datetime.datetime.fromisoformat is picky about fractional seconds:

  • 2020-01-01T12:33:56 :white_check_mark:
  • 2020-01-01T12:33:56.0 :x:
  • 2020-01-01T12:33:56.000 :white_check_mark: (milliseconds)
  • 2020-01-01T12:33:56.0000 :x:
  • 2020-01-01T12:33:56.000000 :white_check_mark: (microseconds)
  • 2020-01-01T12:33:56.00000 :x: # commonly generated by JavaScript libraries
  • 2020-01-01T12:33:56.0000000 :x:
  • 2020-01-01T12:33:56.000000000 :x: (nanoseconds) # golang, tc39 Temporal
9 Likes