Skip to content
New issue

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

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

Already on GitHub? # to your account

Add xsd date type #602

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/saml2/saml.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Generated Mon May 2 14:23:33 2011 by parse_xsd.py version 0.4.
#
import base64
import datetime

from saml2.validate import valid_ipv4, MustValueError
from saml2.validate import valid_ipv6
Expand Down Expand Up @@ -198,6 +199,11 @@ def _wrong_type_value(xsd, value):
'to_type': str,
'to_text': str,
},
'date': {
'type': datetime.date,
'to_type': lambda x: datetime.datetime.strptime(x, '%Y-%m-%d').date(),
Copy link
Member

@c00kiemon5ter c00kiemon5ter May 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is setting a specific time format, whereas xsd:date allows for [-]CCYY-MM-DD[Z\|(+\|-)hh:mm]. I'll probably do #518 first, then point this to the new datetime parser (saml2.datetime.parse) that takes that into account, as well as timezones.

Copy link
Member Author

@peppelinux peppelinux May 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better generalization on top of #518 would be the best solution for taking also datetime as timestamps, with timezone support.

'to_text': str,
},
'integer': {
'type': int,
'to_type': int,
Expand Down