mvantellingen / python-zeep

A Python SOAP client
http://docs.python-zeep.org
Other
1.88k stars 585 forks source link

Timezone is lost for xsd:date value #769

Open wbkoetsier opened 6 years ago

wbkoetsier commented 6 years ago

Zeep 2.5.0 Python 3.6.0 WSDL: http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl

Running

client = Client(wsdl=self.BASE_URL)
response = client.service.checkVat(countryCode='NL', vatNumber='TESTVATNUMBER')

gives me a value of datetime.date(2018, 6, 6) for requestDate. I was a bit suspicious because the time zone is missing here, so I checked the 'raw' XML output:

client = Client(wsdl=self.BASE_URL)
with client.options(raw_response=True):
    response = client.service.checkVat(countryCode='NL', vatNumber='TESTVATNUMBER')

which gives me <requestDate>2018-06-06+02:00</requestDate> (I was expecting a time here too, but the wsdl clearly states that requestDate is in xsd:date format, so no time), so the time zone is actually provided by the service.

What could be the problem here? Any help would be appreciated.

mvantellingen commented 6 years ago

The date is parsed using the isodate module, see https://github.com/mvantellingen/python-zeep/blob/master/src/zeep/xsd/types/builtins.py#L177

Python doesn't support timezones for times. So to support this properly we should always return a datetime object instead of a date object.