Xiaobo Liu
Xiaobo Liu
OpenWrt commands for setting the time: ```shell $ uci get system.@system[0].timezone $ uci set system.@system[0].timezone='Asia/Shanghai' $ uci commit system $ /etc/init.d/system reload $ date ```
The iana-time-zone crate support OpenWrt now: https://github.com/strawlab/iana-time-zone/pull/109 Use chrono + iana-time-zone new version, `chrono::Local` prints out UTC time. https://github.com/strawlab/iana-time-zone/pull/109#issuecomment-1579975176
Where chrono to find the time zone info files?
On OpenWrt print `chrono::Local::now()`, without `TZ` env, output UTC time. ```shell $ ./chrono-demo-uclibc 2023-06-17T03:44:47.615484252+00:00 ``` If use `TZ=CST-8` env, output local time. ``` $ cat /etc/TZ CST-8 $ TZ=CST-8 ./chrono-demo-uclibc...
Maybe I should try installing the timezone package. https://openwrt.org/packages/pkgdata_owrt18_6/zoneinfo-asia
In my scenario, it was solved by manually setting the `TZ` environment: ```rust fn main() { let tz = std::fs::read_to_string("/etc/TZ").unwrap_or("CST-8".to_owned()); std::env::set_var("TZ", tz); // do something } ```
The OpenWrt os-release content: ```shell root@OpenWrt:/# cat /etc/os-release NAME="OpenWrt" VERSION="22.03.4" ID="openwrt" ID_LIKE="lede openwrt" PRETTY_NAME="OpenWrt 22.03.4" VERSION_ID="22.03.4" HOME_URL="https://openwrt.org/" BUG_URL="https://bugs.openwrt.org/" SUPPORT_URL="https://forum.openwrt.org/" BUILD_ID="20231016-1458-g9191cfc-dirty" OPENWRT_BOARD="ramips/mt7621" OPENWRT_ARCH="mipsel_24kc" OPENWRT_TAINTS="no-all busybox" OPENWRT_DEVICE_MANUFACTURER="OpenWrt" OPENWRT_DEVICE_MANUFACTURER_URL="https://openwrt.org/" OPENWRT_DEVICE_PRODUCT="Generic" OPENWRT_DEVICE_REVISION="v0" OPENWRT_RELEASE="OpenWrt 22.03.4...
Wow, that's great!
PR rebase done.
Oh, it looks like `nix` is using the wrong type.