With export TZ='<UTC+8>-8'
you'd be defining the current timezone as being named UTC+8
and being 8 hours ahead of UTC all year round for past, current and future dates.
Then:
$ date +'%::z %Z'
+08:00:00 UTC+8
$ date
Thu 1 Dec 23:04:48 UTC+8 2022
To keep Asia/Taipei
(with its historical changes in timezone), but change what %Z
returns, you'd need to modify and recompile the tzdata from which it is derived.
apt source tzdata
sudo apt build-dep tzdata
Change the Taiwan section to:
# Rule NAME FROM TO - IN ON AT SAVE LETTER/S
Rule Taiwan 1946 only - May 15 0:00 1:00 9
Rule Taiwan 1946 only - Oct 1 0:00 0 8
Rule Taiwan 1947 only - Apr 15 0:00 1:00 9
Rule Taiwan 1947 only - Nov 1 0:00 0 8
Rule Taiwan 1948 1951 - May 1 0:00 1:00 9
Rule Taiwan 1948 1951 - Oct 1 0:00 0 8
Rule Taiwan 1952 only - Mar 1 0:00 1:00 9
Rule Taiwan 1952 1954 - Nov 1 0:00 0 8
Rule Taiwan 1953 1959 - Apr 1 0:00 1:00 9
Rule Taiwan 1955 1961 - Oct 1 0:00 0 8
Rule Taiwan 1960 1961 - Jun 1 0:00 1:00 9
Rule Taiwan 1974 1975 - Apr 1 0:00 1:00 9
Rule Taiwan 1974 1975 - Oct 1 0:00 0 8
Rule Taiwan 1979 only - Jul 1 0:00 1:00 9
Rule Taiwan 1979 only - Oct 1 0:00 0 8
# Zone NAME STDOFF RULES FORMAT [UNTIL]
# Taipei or Taibei or T'ai-pei
Zone Asia/Taipei 8:06:00 - UTC+8:06 1896 Jan 1
8:00 - UTC+8 1937 Oct 1
9:00 - UTC+9 1945 Sep 21 1:00
8:00 Taiwan UTC+%s
Then build the new tzdata
package with:
dpkg-buildpackage -b
Install the generated package.
Then:
$ export TZ=Asia/Taipei
$ date
Thu 1 Dec 23:17:41 UTC+8 2022
$ date -d 1979-08-01
Wed 1 Aug 00:00:00 UTC+9 1979
$ date -d 1892-06-01
Wed 1 Jun 00:00:00 UTC+8:6 1892
You'd need to redo that every time the Ubuntu source package is updated (which happens quite a few times a year, any time any government in any country decides of a new DST change date or rule for instance), so probably not practical.
If it's only date
's output you have issues with, you can also do:
$ date +"$(locale date_fmt | sed 's/%Z/UTC%:z/')"
Fri 2 Dec 00:31:05 UTC+08:00 2022
in place of
$ date
Fri 2 Dec 00:31:05 CST 2022
Or:
$ date +"$(locale d_t_fmt | sed 's/%Z/UTC%:z/')"
Fri 02 Dec 2022 00:33:02 UTC+08:00
in place of:
$ date +%c
Fri 02 Dec 2022 00:33:02 CST
Those:
$ locale -k LC_TIME | grep fmt
d_t_fmt="%a %d %b %Y %T %Z"
d_fmt="%d/%m/%y"
t_fmt="%T"
t_fmt_ampm="%l:%M:%S %P %Z"
era_d_fmt=""
era_d_t_fmt=""
era_t_fmt=""
date_fmt="%a %e %b %H:%M:%S %Z %Y"
Can be changed by compiling a new locale with your preference:
localedef -i <(sed 's/%Z/UTC%z/g' /usr/share/i18n/locales/en_GB) \
-f UTF-8 ~/.locales/en_GB.UTF-8@mytimezoneformat
export LOCPATH=~/.locales LC_TIME=en_GB.UTF-8@mytimezoneformat
(above installed in my home directory, but you could also do it system-wide and not to have to set $LOCPATH
).
Then:
$ date
Fri 2 Dec 01:11:16 UTC+0800 2022
$ date +%c
Fri 02 Dec 2022 01:11:20 UTC+0800
man date
?