コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
6261 ビュー

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?

アバター
破棄
著作者

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.

著作者 最善の回答

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!

アバター
破棄
関連投稿 返信 ビュー 活動
1
1月 24
8539
0
3月 15
5700
2
12月 23
16823
1
3月 15
3248
1
9月 20
5948