为什么Git有下午茶时间?


102

在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小时)?这只是某种复活节彩蛋吗?

Answers:


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?还是有一些后编译步骤可以指定这些步骤?
乔纳·毕晓普

1
我对近似值及其答案的工作方式还不太熟悉。从缺乏文档的角度来看,我可能会说是-您需要重新编译git才能支持它。
Axel

38
@JonahBishop,你不知道吗?你可以有,如果你修改源并重新编译自定义功能....
保罗·德雷珀

1
@jhpratt我在这里没问题。没有人保证过如此容易地使用您添加的自定义设置。
Atomosk

1
@jhpratt Build系统很有趣,要么习惯它,要么解决问题,并为免费的开源项目做贡献。
Sergio Basurco
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.