为什么Git要有茶歇时间?

101
在Git源代码的date.c文件中,我注意到特殊时间名称的以下结构:
static const struct special {
    const char *name;
    void (*fn)(struct tm *, struct tm *, int *);
} special[] = {
    { "yesterday", date_yesterday },
    { "noon", date_noon },
    { "midnight", date_midnight },
    { "tea", date_tea },
    { "PM", date_pm },
    { "AM", date_am },
    { "never", date_never },
    { "now", date_now },
    { NULL }
};

我有点理解大多数这些工具的用途,但是为什么要设置一个“茶时间”(它会被转换为17:00小时)?这只是某种彩蛋吗?

1个回答

65
这个提交可能会给你一个线索,解释为什么它被包含在内: https://github.com/git/git/commit/a8aca418d6484400d6804e22717bd49ca06c28e9 我认为最初是作为一个玩笑提出的建议,但实际上是为了展示用户能够包含自己的自定义时间/日期段的能力而实现的。
On Fri, 18 Nov 2005, David Roundy wrote:
> Don't forget "high noon"!  (and perhaps "tea time"?)  :)


Done.

    [torvalds@g5 git]$ ./test-date "now" "midnight" "high noon" "tea-time"
    now -> bad -> Wed Dec 31 16:00:00 1969
    now -> Fri Nov 18 08:50:54 2005

    midnight -> bad -> Wed Dec 31 16:00:00 1969
    midnight -> Fri Nov 18 00:00:00 2005

    high noon -> bad -> Wed Dec 31 16:00:00 1969
    high noon -> Thu Nov 17 12:00:00 2005

    tea-time -> bad -> Wed Dec 31 16:00:00 1969
    tea-time -> Thu Nov 17 17:00:00 2005

Thanks for pointing out tea-time.

This is also written to easily extended to allow people to add their own
important dates like Christmas and their own birthdays.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>

2
那么,要添加一个新的自定义日期,是不是需要重新编译带有特定更改的Git?还是有一些后编译步骤可以指定这些内容? - Jonah Bishop
1
我对approxidate及其工作原理不够熟悉,无法回答。根据它缺乏文档的情况来看,我可能会说是的 - 您需要重新编译git以支持它。 - Axel
38
@JonahBishop,难道你不知道吗?如果你修改源代码并重新编译它,你就可以拥有自定义功能... - Paul Draper
1
@jhpratt 我在这里看不到任何问题。没有人承诺使用你所添加的自定义内容会很容易。 - Atomosk
1
@jhpratt 构建系统就是这样有趣,要么习惯它,要么解决问题并为自由开源项目做出贡献。 - Sergio Basurco
显示剩余2条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接