Skip to content
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

please parse slightly wrong-formatted timestamps #165

Open
dorchain opened this issue Apr 2, 2021 · 1 comment
Open

please parse slightly wrong-formatted timestamps #165

dorchain opened this issue Apr 2, 2021 · 1 comment

Comments

@dorchain
Copy link

dorchain commented Apr 2, 2021

Hi,

I found a server ( https://www.officeholidays.com/ics/germany/) that returns calendar entries with timestamps like this:
20210402T63058Z Obviously this is not a valid DATE-TIME. IMHO this is meant to be 20210402T063058Z (Note the 0 after the T for 2 digit hour)

Please consider autocorrecting this, e.g. with the patch below:

--- icalendar.py.orig   2021-04-02 14:07:52.618401523 +0200
+++ icalendar.py        2021-04-02 14:09:18.279702313 +0200
@@ -1727,6 +1727,10 @@
     """
     Returns datetime.datetime object.
     """
+    t=s[9:]
+    # assume the missing digit is a 0 in front of the hour
+    if len(t.split('Z')[0]) < 6:
+        s = s[:9] + '0' + t
     try:
         year = int(s[0:4])
         month = int(s[4:6])

@da4089
Copy link
Collaborator

da4089 commented Feb 27, 2024

@dorchain, I had a quick look at the latest file from this site, and it appears that they have fixed this problem (although all the timestamps are now either midnight or 080000, so it might be a workaround).

Given that this was clearly a bug on their part, and it's now fixed, I think it's best not to clutter the code with this (now not needed) workaround.

Apologies for the delay in responding, and thanks for the report, nonetheless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants