Skip to content

Consider moving to isodate.parse_datetime as date time string unmarsaller #235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
playpauseandstop opened this issue Apr 10, 2020 · 1 comment · Fixed by #237
Closed
Labels
area/unmarshalling Indicates an issue on unmarshalling area. kind/bug/confirmed

Comments

@playpauseandstop
Copy link

I've run into issue when default format_datetime unmarshaller strips date time TZ as their code,

    timestamp = strict_rfc3339.rfc3339_to_timestamp(value)
    return datetime.datetime.utcfromtimestamp(timestamp)

convert datetime string to timestamp and create new datetime.datetime instance without tzinfo.

This means, for schema,

  value:
    type: "string"
    format: "date-time"

request or parameter data,

{"value": "2020-04-01T12:00:00+02:00"}

will result in value of datetime.datetime(2020, 4, 1, 10, 0, 0, tzinfo=None) (tz naive datetime value) instead of tz aware datetime value.

I've managed to fix it by supplying isodate.parse_datetime as unmarshaller for date-time strings in playpauseandstop/rororo#39 and would like to ask you consider change current format_datetime unmarshaller to parse_datetime function instead.

@p1c2u p1c2u added area/unmarshalling Indicates an issue on unmarshalling area. kind/bug/confirmed labels Apr 11, 2020
@playpauseandstop
Copy link
Author

Thanks a lot for a quick fix! I appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/unmarshalling Indicates an issue on unmarshalling area. kind/bug/confirmed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants