Feb-01-2022, 09:50 PM
Now that pendulum is working, I have a question about daylight savings time & pendulum.
The program that I am writing fires off tasks ever 15 minutes between sunrise and sunset and currently used datetime.
What pendulum command would I run to get the current time when in daylight savings time or not? As I read the pendulum documentation and run my test, I can get hours but not minutes.
Here is one of my test & output. The time I ran it was 15:18 local time today. I was expecting something like 15:18 or 3:18 but none of these results seem to be correct.
The program that I am writing fires off tasks ever 15 minutes between sunrise and sunset and currently used datetime.
What pendulum command would I run to get the current time when in daylight savings time or not? As I read the pendulum documentation and run my test, I can get hours but not minutes.
Here is one of my test & output. The time I ran it was 15:18 local time today. I was expecting something like 15:18 or 3:18 but none of these results seem to be correct.
import pendulum # Gets the timezone instance print(pendulum.now().timezone) print(pendulum.now().tz) # Gets the timezone name print(pendulum.now().timezone_name) # Indicates if daylight savings time is on dt = pendulum.datetime(2022, 1, 1, tz='America/Chicago') print(dt) dt = pendulum.datetime(2022, 7, 1, tz='America/Chicago') print(dt)
Output:pi@raspberrypi:~ $ python3 pendulum1.py
Timezone('America/Chicago')
Timezone('America/Chicago')
America/Chicago
2022-01-01T00:00:00-06:00
2022-07-01T00:00:00-05:00
pi@raspberrypi:~ $