ermakov-oleg / serpyco-rs

Fast Python dataclasses serialization
MIT License
30 stars 2 forks source link

Can't parse datetime from string with high millisecond precision #142

Closed arck1 closed 6 months ago

arck1 commented 7 months ago

Hi, I'm getting an error when parsing dates with high millisecond precision.

Example

from datetime import datetime

from serpyco_rs import Serializer

serializer = Serializer(datetime)
obj = serializer.load('2024-04-02T12:21:53.725421224')
print(obj)

Expected print datetime object

Actual

serpyco_rs.SchemaValidationError: Schema validation failed:
- "2024-04-02T12:21:53.725421224" is not of type "datetime" (instance_path='')

Info: serpyco-rs version: 1.6.0 python: 3.12.2 os: macos 14.3.1 (m1)

Comment string "2024-04-02T12:21:53.725421224" get from Java springframework which use LocalDateTime.now()