經過幾天的搜索並嘗試使用pytz和其他工具,我無法找到解決方案。GNU Health - 時區錯誤
當用戶創建在GNU衛生給出錯誤的藥物打印出清單:
====== ERROR=======================
Traceback (most recent call last):
File "/trytond/protocols/jsonrpc.py", line 150, in _marshaled_dispatch
response['result'] = dispatch_method(method, params)
File "/trytond/protocols/jsonrpc.py", line 179, in _dispatch
res = dispatch(*args)
File "/trytond/protocols/dispatcher.py", line 161, in dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
File "/trytond/report/report.py", line 144, in execute
type, data = cls.parse(action_report, records, data, {})
File "/trytond/modules/health/report/health_report.py", line 62, in parse
localcontext['print_date'] = get_print_date()
File "/trytond/modules/health/report/health_report.py", line 42, in get_print_date
return datetime.astimezone((dt.replace(tzinfo=None))
TypeError: astimezone() argument 1 must be datetime.tzinfo, not None
============END=================
我不知道如何解決這個問題,
是什麼'datetime.astimezone((dt.replace(tzinfo =無))'應該做的 –
? @PadraicCunningham:我會理解它是否會引發:'ValueError:astimezone()不能應用於天真的日期時間,那麼它將等於 'dt.replace(tzinfo = None).astimezone()', TypeError'建議'datetime.now(timezone.utc).astimezone(tz = None)'類似代碼(在Python 3.3+之前 其中空參數被設置爲本地時區: ['.astimezone(tz)':* Changed在版本3.3中:tz現在可以省略*](https://docs.python.org/3/library/datetime.html#datetime.dateti me.astimezone)。無論如何,使用'klass.method(obj,* args)' 而不是'obj.method(* args)'是一種不好的風格。 – jfs