Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
6136 Zobrazení

Why is it that hr_timesheet_invoice_create.py needs

from dateutil import tz
from_zone = tz.tzutc()
to_zone = tz.tzlocal()
arrive = arrive.replace(tzinfo=from_zone)
arrive_central = arrive.astimezone(to_zone)

to display the correct time information?

Avatar
Zrušit
Autor

And it seems .mako files are even further away from displaying the correct time information. This code doesn't work in mako files; I still get UTC.

Autor Nejlepší odpověď

The following code works fine in my makos.

import pytz
# ...
time_local = 'America/Chicago'
time_fmt = "%Y-%m-%d %H:%M"
arrive_dt = datetime.utcnow()
testDt=pytz.utc.localize(arrive_dt)
TestDt = testDt.astimezone(pytz.timezone(time_local))
Arrive=TestDt.strftime(time_fmt)

Good luck!

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
led 24
8464
0
bře 15
5536
2
pro 23
16658
1
bře 15
3183
1
zář 20
5866