GeoNet / fdsn

FDSN Web Services
MIT License
17 stars 15 forks source link

Timezone error - Bad Request: converting value. #236

Open vlauciani opened 1 year ago

vlauciani commented 1 year ago

A requeste like:

return an error:

Error 400: Bad Request
schema: error converting value for "starttime". Details: parsing time "2021-10-06T00:00:00.000Z00000Z": extra text: "00000Z" (and 1 other error)
Usage details are available from https://www.geonet.org.nz/data/tools/FDSN
Request:
/fdsnws/station/1/query?endtime=2021-10-06T23:59:59.000Z&level=station&starttime=2021-10-06T00:00:00.000Z
Request Submitted:
2023-06-02T00:26:19+12:00
Service version:
1.1

I think that the problem is the timezone reported with "Z" letter.

junghao commented 1 year ago

Based on FDSN specification https://www.fdsn.org/webservices/FDSN-WS-Specifications-1.2.pdf:

All ​time​ values are specified in UTC and should use one particular variation of the ISO 8601 standard with the addition of sub-seconds:
YYYY-MM-DD​T​HH:MM:SS.ssssss

Where the fields are as specified in ISO 8601 and a “T” separates the date and time. The “​ssssss​” are the sub-seconds expressed between 1/10 of a second to microsecond resolution; they do not all need to be present.
Two shorter variations for specifying time should be supported:
YYYY-MM-DD​T​HH:MM:SS (implies a time of ​YYYY-MM-DD​T​HH​:​MM​:​SS​.000000)
where the sub-seconds are interpreted to be zeros and
YYYY-MM-DD (implies a time of ​YYYY-MM-DD​T00:00:00.000000)
where the hour, minute, second and sub-second are interpreted to be zeros.

However, the error message has extra .00000Z should be removed.

elidana commented 1 year ago

the same request without Z works fine

https://service.geonet.org.nz/fdsnws/station/1/query?level=station&starttime=2021-10-06T00:00:00.000&endtime=2021-10-06T23:59:59.000

ozym commented 1 year ago

This is something that's likely to be updated in the future, as per the recent changes to stationxml regarding Z

vlauciani commented 1 year ago

Thanks @elidana , the request without Z works fine... but Z is part of ISO8601:

This is the only FDSN service where I got this error. I should update my script to remove the Z letter when the request will be submitted to the GeoNet FDSN; I'll do that, no problem.


Looking the FDSN-Spec (https://www.fdsn.org/webservices/FDSN-WS-Specifications-1.2.pdf), the misunderstand is the frase:

All ​time​ values are specified in UTC and should use one particular variation of the ISO 8601 standard with the addition of sub-seconds:
YYYY-MM-DD​T​HH:MM:SS.ssssss

which is in contrast with Wiki (https://en.wikipedia.org/wiki/ISO_8601):

[...] if no time zone information is provided with a time representation, it should be interpreted as local time
Screenshot 2023-06-05 at 10 04 57

Anyway, it's not a problem for me to fix this.

Thanks for the support.