mirror of
https://github.com/git-for-windows/git.git
synced 2026-06-11 19:37:52 -05:00
There are cases where the "wrap-to-yesterday" behavior of "tea" and "noon" should be reverted later on down the line, so that "today tea" and "tea today" won't yield different results. However, the logic of approxidate doesn't seem to lend itself particularly well to such cases. Start tackling the issue by reusing negative values of `tm->tm_mday` field for deferred date adjustments which can be easily reverted, so that the default logic of the special formats only applies if we don't get any explicit date (mday) specification. In particular, overwrite the field with -1 in "today" and "yesterday", so that those formats will be relative to the current date. That makes specifications like "tea yesterday" behave more sensibly: instead of going backwards to the last tea-time and then a day back, Git will now understand that as the tea-time of yesterday. Replace the call of `update_tm()` in `date_time()` with the assignment `tm->tm_mday = -2`. Add the corresponding code to handle that in `update_tm()`, wrapping to the previous day if the field still holds such assignment, meaning that we haven't seen any better specification for the day-of-month. On the other hand, `mday=-3` would mean going two days back and so on. Even though such functionality isn't actually needed by this patch, it won't add much complexity in the code and is rather natural way to handle such values. As `date_time()` won't no longer need the `now` struct, mark the associated function parameters as unused. The parameters themselves have to stay, however, as those functions are called through pointers in `approxidate_alpha`. Add relevant tests to cover the changes. Signed-off-by: Tuomas Ahola <taahol@utu.fi> Signed-off-by: Junio C Hamano <gitster@pobox.com>
34 KiB
34 KiB