{"thread":{"id":"64993","subject":"Question: --since date parsing uses current time instead of midnight - by design?","startedAt":"2026-02-13T21:17:15Z","lastAt":"2026-02-14T22:11:12Z","messageCount":3,"participants":["gregor@chkpnt.de","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"535965","messageId":"e5904a7b-c146-4c36-8b87-c5c508e14cca@chkpnt.de","threadId":"64993","inReplyTo":null,"subject":"Question: --since date parsing uses current time instead of midnight - by design?","fromName":"","fromEmail":"gregor@chkpnt.de","sentAt":"2026-02-13T21:09:29Z","receivedAt":"2026-02-13T21:17:15Z","isPatch":false,"sender":{"key":"gregor@chkpnt.de","avatar":null},"body":"Hello,\n\nI've just noticed how git log --since=<date> interprets dates without \nexplicit times, and I found the behavior seems potentially unintended. \nI'd like to understand if this is by design or a bug.\n\nWhen using --since=\"2026-02-09\" (date without time), Git uses the \ncurrent local time at command execution, not midnight (00:00:00) as \nusers might expect.\n\nFor example:\n\n     Running git log --since=\"2026-02-09\" at 21:20:00 interprets it as \n\"2026-02-09 21:20:00\"\n\n     Running the same command at 09:00:00 interprets it as \"2026-02-09 \n09:00:00\"\n\nThis means the same command returns different results depending on when \nit's executed.\n\nRoot Cause (in date.c)\n\nThe issue stems from the two-stage parsing in approxidate_careful():\n1) parse_date_basic() parses the date fields (year, month, day) but \nfails because time fields remain at -1, causing tm_to_time_t() to return -1\n2) Falls back to approxidate_str(), which:\n   - Calls localtime_r() to initialize tm with current time\n   - Resets only date fields to -1 (year, mon, mday)\n   - Re-parses the string, overwriting date fields\n   - Time fields retain values from current local time\n   - update_tm() calls mktime() with this mixed result\n\nIs this behavior intentional? The approxidate mechanism is designed to \nbe \"human-friendly,\" but this seems like an edge case where users likely \nexpect --since=\"2026-02-09\" to mean midnight.\n\nExplicitly specifying the time works correctly as a workaround:\n\n--since=\"2026-02-09 00:00:00\"\n--since=\"2026-02-09T00:00:00\"\n\nShould this behavior be documented, or would a patch to default to \nmidnight be appropriate?\n\nRegards,\nGregor\n"},{"id":"535973","messageId":"xmqq8qcwjmgh.fsf@gitster.g","threadId":"64993","inReplyTo":"e5904a7b-c146-4c36-8b87-c5c508e14cca@chkpnt.de","subject":"Re: Question: --since date parsing uses current time instead of midnight - by design?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-13T22:41:18Z","receivedAt":"2026-02-13T22:41:21Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"gregor@chkpnt.de writes:\n\n> Hello,\n>\n> I've just noticed how git log --since=<date> interprets dates without \n> explicit times, and I found the behavior seems potentially unintended. \n> I'd like to understand if this is by design or a bug.\n\nLooks like it is very much designed, ...\n\nhttps://lore.kernel.org/git/Pine.LNX.4.64.0511171505080.13959@g5.osdl.org/\n\n... at least to me.\n"},{"id":"536031","messageId":"xmqq3433gema.fsf@gitster.g","threadId":"64993","inReplyTo":"xmqq8qcwjmgh.fsf@gitster.g","subject":"Re: Question: --since date parsing uses current time instead of midnight - by design?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-14T22:11:09Z","receivedAt":"2026-02-14T22:11:12Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> gregor@chkpnt.de writes:\n>\n>> Hello,\n>>\n>> I've just noticed how git log --since=<date> interprets dates without \n>> explicit times, and I found the behavior seems potentially unintended. \n>> I'd like to understand if this is by design or a bug.\n>\n> Looks like it is very much designed, ...\n>\n> https://lore.kernel.org/git/Pine.LNX.4.64.0511171505080.13959@g5.osdl.org/\n>\n> ... at least to me.\n\nWith hindsight, it looks to me that both conventions are equally\nlegit.  If you extend a low-resolution time specification (e.g.,\ndate only without hours and minutes) to use the current time, which\nis what Linus decided to do, that is one valid convention.  You can\nchoose to extend lower bits to zero (e.g., date only without hours\nand minutes means midnight at the beginning of that day), that is\nequally valid.\n\nThe former, however, is more convenient than the latter for humans.\nYou can ask \"what did we in the past 24-hours?\" more easily.  And if\nyou really care to give the midnight, filling the lower bits to zero\nyourself is not that hard, compared to having to fill the lower bits\nwith the current time.  So it would be an overall win for both use\ncases.\n\n\n"}]}