git 2.7(2015 年第 4 季度)可以实现这一点,它引入了-local
作为指示。
这意味着,除了:
--date=(relative|local|default|iso|iso-strict|rfc|short|raw)
您还将拥有:
--date=(relative-local|default-local|iso-local|iso-strict-local|rfc-local|short-local|raw-local)
您现在可以要求任何日期格式使用当地时区.
在你的情况下:
git log --date=iso-local -3 --pretty=tformat:'%cd %h' --abbrev-commit
^^^^^^^^^
|____| that part is new!
See commit 99264e9 https://github.com/git/git/commit/99264e93fc87bdd61f646c53878782947d476da8, commit db7bae2 https://github.com/git/git/commit/db7bae25ed8e80a7afad9a6a9240819528c5192c, commit dc6d782 https://github.com/git/git/commit/dc6d782c5d2526b251061daffc3e74d15c8c7095, commit f3c1ba5 https://github.com/git/git/commit/f3c1ba502628cf0b6e8674f07c3850b21f365965, commit f95cecf https://github.com/git/git/commit/f95cecf43335dd8e80e954c2f998dc0e8b0dd070, commit 4b1c5e1 https://github.com/git/git/commit/4b1c5e1d268fa1e7b4344e7d94de1edc5ead49a5, commit 8f50d26 https://github.com/git/git/commit/8f50d263d70702c9409eb17cce10ea5b0831223a, commit 78a8441 https://github.com/git/git/commit/78a844160bd1273bad89fdc0df13a1037ab4b1a4, commit 2df4e29 https://github.com/git/git/commit/2df4e29c85dee2fe8b89e7878a38b59062e103ef (03 Sep 2015) by John Keeping (johnkeeping) https://github.com/johnkeeping.
See commit add00ba https://github.com/git/git/commit/add00ba2de971e0c5ba00f1f02b73c5534079d2c, commit 547ed71 https://github.com/git/git/commit/547ed71636dbfab2dc303ba8cabb29c2cab22f1e (03 Sep 2015) by Jeff King (peff) https://github.com/peff.
(Merged by Junio C Hamano -- gitster -- https://github.com/gitster in commit 7b09c45 https://github.com/git/git/commit/7b09c459d346d9bf30ab07921a9b0ee91405d104, 05 Oct 2015)
尤其,提交add00ba https://github.com/git/git/commit/add00ba2de971e0c5ba00f1f02b73c5534079d2c提到:
date
: make "local
" 正交于日期格式:
我们大部分的“--date
“模式与日期的格式有关:我们显示哪些项目以及按什么顺序显示。
But "--date=local
”有点奇怪。它的意思是“以正常格式显示日期,但使用当地时区”。
我们使用的时区与实际格式正交,并且我们没有理由不能使用“本地化的 iso8601”等。
这个补丁添加了一个“local
“布尔字段到”struct date_mode
”,并删除DATE_LOCAL
元素来自于date_mode_type
枚举(现在只是DATE_NORMAL
plus local=1
).
用户可以通过添加“-local
“ 到任何日期模式(例如,“iso-local
”),并且我们保留“local
“ 作为” 的别名default-local
“为了向后兼容。