Python script: Error executing script: Not allowed to access module.strptime

I’ve written a python_script that fetches a string via the Google Calendar Event module. That module finds the next appointment in a certain Google calendar.

In the python script, I want to transform the string into a datetime object, so that I can perform some calculations with it afterwards (to calculate at what time to set my alarm clock).

My statement:
alarm_date_object = datetime.strptime(next_appointment_string, ‘%Y-%m-%d %H:%M:%S’)

Returns:
Error executing script: Not allowed to access module.strptime

Can I avoid this from happening?
I read here that strftime support was added to HA (convert datetime object to string), but in this case I need to do the opposite, so strptime. Does the datetime module work in python_script?

Does anyone know the answer?

I worked around the issue by using str.split() and str.replace() to fetch the date and time from the string.

I wrote one python_script and found the process a bit, um, frustrating. I don’t think you can import modules. And even some basic Python stuff wouldn’t work very well. (E.g., I had a few list comprehensions, and some would work, but others would fail in weird ways, even though they all worked fine when tested directly in a Python shell. Also, you can’t even do “list(iterable)”, but you can do “tuple(iterable)”.) These scripts run in a “sandbox”, and that sandbox doesn’t have many toys in it. :frowning: But I did eventually get my script working, although looking at it you would think I’ve never written Python code before because of all the workarounds I had to do. I kind of understand the reason for a sandbox, but it seems to me it’s way too restrictive.