python - Python (PyPy) times.to_universal() 在 Alpine linux 上不起作用
问题描述
timezone
我在 Alpine linux 容器中使用时间转换器时遇到问题,无论我指定什么,它都会导致相同的时间。与我的本地主机 Ubuntu 相比,结果是具有相同times
版本的不同事件。
times==0.7
在两个系统上
在 Alpine Docker 容器上,我tzdata
在 CET 和 localhost 上安装并正确设置了时区。它显示命令的相同日期/时间date
。
alpine-pypy:3.6-7-alpine3.9 容器,root 用户
Python 3.6.1 (de061d87e39c7df4e436974096d7982c676a859d, Mar 25 2019, 18:43:49)
[PyPy 7.1.0-beta0 with GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: ``I might, but nobody respects me''
>>>> import times
>>>> from datetime import datetime
>>>> times.to_universal(datetime(2017, 12, 24, 13, 50, 24, 124), 'CET')
datetime.datetime(2017, 12, 24, 13, 50, 24, 124)
>>>> times.to_universal(datetime(2017, 12, 24, 13, 50, 24, 124), 'Japan')
datetime.datetime(2017, 12, 24, 13, 50, 24, 124)
>>>> times.to_universal(datetime(2017, 12, 24, 13, 50, 24, 124))
datetime.datetime(2017, 12, 24, 13, 50, 24, 124)
在本地主机 Ubuntu 20.04 上,pypy3
Python 3.6.9 (7.3.2+dfsg-2~ppa1~ubuntu20.04, Sep 26 2020, 22:37:47)
[PyPy 7.3.2 with GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>> import times;from datetime import datetime
>>>> times.to_universal(datetime(2017, 12, 24, 13, 50, 24, 124), 'CET')
datetime.datetime(2017, 12, 24, 12, 50, 24, 124)
>>>> times.to_universal(datetime(2017, 12, 24, 13, 50, 24, 124), 'Japan')
datetime.datetime(2017, 12, 24, 4, 50, 24, 124)
>>>> times.to_universal(datetime(2017, 12, 24, 13, 50, 24, 124))
datetime.datetime(2017, 12, 24, 13, 50, 24, 124)
Dockerfile 重现
FROM jamiehewland/alpine-pypy:3.6-7-alpine3.9
#FROM python:3.7.9-alpine3.11
ENV TZ CET
RUN apk update && apk upgrade \
&& apk add bash libxml2-dev libxslt-dev build-base tzdata \
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone
RUN pip install --upgrade pip setuptools
RUN pip install times==0.7
请问有什么建议吗?
解决方案
推荐阅读
- html - 合并/重叠列 bootstrap v4 小屏幕
- google-cloud-pubsub - Micronaut 3:如何使用 PubSubEmulatorContainer
- javascript - 如何从初始状态数组 redux/toolkit 打字稿中删除对象
- android-room - 房间刷新查询结果
- architecture - 如何处理事件驱动架构中缺乏无限保留的问题?
- swift - NavigationLink 内部的 UIViewControllerRepresentable
- c - kill(pid,SIGTERM) 终止子进程,尽管 pid 是父进程
- c - 在 C 文件中使用外部头文件从 Rust 调用 C
- angular - Angular - 如何从另一个组件调用和激活函数
- javascript - 在我当前的实现中应用从下一页获取链接的逻辑时遇到问题