c10*_*c10 12 command-line time date coreutils
有人可以帮助我理解为什么添加任何小写字母 (az) 如下所示会对 date -d 输出产生影响,以及该命令中的这些字母是什么意思?
\nwip$ date -d "12:24 a"\nMon Apr 18 18:54:00 IST 2022\nwip$ date -d "12:24 b"\nMon Apr 18 19:54:00 IST 2022\nwip$ date -d "12:24 c"\nMon Apr 18 20:54:00 IST 2022\nwip$ date -d "12:24 d"\nMon Apr 18 21:54:00 IST 2022\nwip$ date -d "12:24 e"\nMon Apr 18 22:54:00 IST 2022\nwip$ date -d "12:24 f"\nMon Apr 18 23:54:00 IST 2022\nwip$ date -d "12:24 g"\nTue Apr 19 00:54:00 IST 2022\nwip$ date -d "12:24 h"\nTue Apr 19 01:54:00 IST 2022\nwip$ date -d "12:24 i"\nTue Apr 19 02:54:00 IST 2022\nwip$ date -d "12:24 j"\ndate: invalid date \xe2\x80\x9812:24 j\xe2\x80\x99\nwip$ date -d "12:24 k"\nTue Apr 19 03:54:00 IST 2022\nwip$ date -d "12:24 l"\nTue Apr 19 04:54:00 IST 2022\nwip$ date -d "12:24 m"\nTue Apr 19 05:54:00 IST 2022\nwip$ date -d "12:24 n"\nMon Apr 18 16:54:00 IST 2022\nwip$ date -d "12:24 o"\nMon Apr 18 15:54:00 IST 2022\nwip$ date -d "12:24 p"\nMon Apr 18 14:54:00 IST 2022\nwip$ date -d "12:24 q"\nMon Apr 18 13:54:00 IST 2022\nwip$ date -d "12:24 r"\nMon Apr 18 12:54:00 IST 2022\nwip$ date -d "12:24 s"\nMon Apr 18 11:54:00 IST 2022\nwip$ date -d "12:24 t"\nMon Apr 18 10:54:00 IST 2022\nwip$ date -d "12:24 u"\nMon Apr 18 09:54:00 IST 2022\nwip$ date -d "12:24 v"\nMon Apr 18 08:54:00 IST 2022\nwip$ date -d "12:24 w"\nMon Apr 18 07:54:00 IST 2022\nwip$ date -d "12:24 x"\nMon Apr 18 06:54:00 IST 2022\nwip$ date -d "12:24 y"\nMon Apr 18 05:54:00 IST 2022\nwip$ date -d "12:24 z"\nMon Apr 18 17:54:00 IST 2022\n
Run Code Online (Sandbox Code Playgroud)\n手册页没有帮助。
\n我还发现在字母表之前添加 + 或 - 会给出相同的输出。
\nwip$ date -d "12:24 -a"\nMon Apr 18 18:54:00 IST 2022\nwip$ date -d "12:24 +a"\nMon Apr 18 18:54:00 IST 2022\n
Run Code Online (Sandbox Code Playgroud)\n谢谢你的帮助。
\nmur*_*uru 22
启用调试输出,我们可以知道它们被解析为时区说明符:
\n% date -d "12:24 v" --debug\ndate: parsed time part: 12:24:00\ndate: parsed zone part: UTC-09\ndate: input timezone: parsed date/time string (-09)\ndate: using specified time as starting value: \'12:24:00\'\ndate: using current date as starting value: \'(Y-M-D) 2022-04-18\'\ndate: starting date/time: \'(Y-M-D) 2022-04-18 12:24:00 TZ=-09\'\ndate: \'(Y-M-D) 2022-04-18 12:24:00 TZ=-09\' = 1650317040 epoch-seconds\ndate: timezone: system default\ndate: final: 1650317040.000000000 (epoch-seconds)\ndate: final: (Y-M-D) 2022-04-18 21:24:00 (UTC)\ndate: final: (Y-M-D) 2022-04-19 06:24:00 (UTC+09)\n
Run Code Online (Sandbox Code Playgroud)\n深入研究源代码,这些在gnulib
\的日期时间解析代码中指定:
% date -d "12:24 v" --debug\ndate: parsed time part: 12:24:00\ndate: parsed zone part: UTC-09\ndate: input timezone: parsed date/time string (-09)\ndate: using specified time as starting value: \'12:24:00\'\ndate: using current date as starting value: \'(Y-M-D) 2022-04-18\'\ndate: starting date/time: \'(Y-M-D) 2022-04-18 12:24:00 TZ=-09\'\ndate: \'(Y-M-D) 2022-04-18 12:24:00 TZ=-09\' = 1650317040 epoch-seconds\ndate: timezone: system default\ndate: final: 1650317040.000000000 (epoch-seconds)\ndate: final: (Y-M-D) 2022-04-18 21:24:00 (UTC)\ndate: final: (Y-M-D) 2022-04-19 06:24:00 (UTC+09)\n
Run Code Online (Sandbox Code Playgroud)\n它们是军事时区。来自维基百科:
\n\n\n军事时区在 ACP 121(I) 标准中定义,澳大利亚、加拿大、新西兰、英国、美国和许多其他国家/地区的武装部队使用该标准。这些名称\n与北约拼音字母\n相同。
\n从格林威治的本初子午线向东,字母“Alpha”到“Mike”(跳过“J”,见下文)代表 12 个具有正UTC\n偏移的时区,直到\n到达国际 Date\nLine。从格林威治向西,字母\n“November”到“Yankee”代表负偏移量的区域。
\n这些字母通常与军事时间结合使用。\n例如,6:00\xc2\xa0a.m。在\n UTC\xe2\x88\x925区域\n 写为“0600R”,口语为“零六百罗密欧”。
\n
归档时间: |
|
查看次数: |
855 次 |
最近记录: |