Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pendulum Help Please
#4
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.

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:~ $
Reply


Messages In This Thread
Pendulum Help Please - by bill_z - Feb-01-2022, 02:49 PM
RE: Pendulum Help Please - by ibreeden - Feb-01-2022, 03:20 PM
RE: Pendulum Help Please - by bill_z - Feb-01-2022, 03:43 PM
RE: Pendulum Help Please - by bill_z - Feb-01-2022, 09:50 PM
RE: Pendulum Help Please - by bowlofred - Feb-02-2022, 01:40 AM
RE: Pendulum Help Please - by snippsat - Feb-02-2022, 06:42 AM
RE: Pendulum Help Please - by ibreeden - Feb-02-2022, 09:02 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020