As you know, most countries use the notion of the "Common Era", which is traditionally linked to the Christian religion. For instance, Unix epoch time is being counted from January 1, 1970. However, if using Unix epoch itself as a point of reference, this same date would be displayed as January 1, 1; January 1, 2020 would be January 1, 51 etc.
How can I tweak my system so that it would display the current year according to this custom frame of reference, and automatically change it each new year as needed?
答案1
You would have to build a custom locale definition, which would essentially be a straight copy of the locale you have used normally so far, except for a custom name and the era
parameters in the LC_TIME part of the locale definition. You might also need to adjust the date formatting strings to display the years according to your alternative calendar.
Here's a link to the Single Unix Specification's definition of the standard syntax of locale definitions: https://pubs.opengroup.org/onlinepubs/007908799/xbd/locale.html
You would then use the localedef
command (or its locale-gen
wrapper script in Debian/Ubuntu and related distributions) to build a binary representation of your custom locale, and install it in the proper location. After that it should be just a matter of setting the LC_TIME
environment variable to tell the system that you want to use your custom locale in matters related to displaying time values. The system-wide default value for this variable can often be defined in either /etc/default/locale
or /etc/sysconfig/i18n
or by using the localectl
command, depending on distribution.
(This is also how the Japanese way of counting years of each reigning emperor is handled: on 1 May 2019, as the new emperor Naruhito ascended the throne, it started a new era in the Japanese calendar, and so year 2019 is presented in Japanese traditional calendar as Reiwa 1/Heisei 31. Reference: https://www.ewc.co.jp/Pages/Information/CalendarEN.aspx)
通过这种方式,您的系统将保留在“公共时代”日历中显示时间的能力,这对于电子邮件标题等内容很重要:发送带有意外年份数字的电子邮件将是过滤外发电子邮件的好方法被其他邮件服务器视为垃圾邮件。
答案2
你不能。
Linux内核内部的时间测量有固定的格式。
然而,可以为此使用不同的时间格式。这些在“区域设置”中定义。因此,系统内部仍将使用美国和国际标准,但显示不同的格式。
一个用于读取系统时间并以不同格式显示它的第三方程序是卡达特。