git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/3] date: add helpers to convert between "+HHMM" timezones and minutes

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 30, 2026, 19:54 UTC
Message-ID
<xmqqa4oya51p.fsf@gitster.g>
In-Reply-To
<CAOLa=ZQRDVL2Djh4du1zWGg_ABZTyzaWDYYb0PDg3EXAfpn7bA@mail.gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 9 quoted lines
>> -	int minutes;
>> +	int minutes = tz < 0 ? -tz : tz;
>
> This is the part which we could skip as we're C99 compliant, but keeping
> to be on the safe side.
>
>> +	minutes = (minutes / 100) * 60 + (minutes % 100);
>> +	return tz < 0 ? -minutes : minutes;
>> +}
I was wondering exactly the same thing yesterday.

As written, it is clear even to those unfamiliar with the C89/C99 signed division rules, because we deal only with non-negative numbers, which is a plus. The fewer things readers need to worry about, the better.

Show 7 quoted lines
>>  	offset /= 60; /* in minutes */
>> -	offset = (offset % 60) + ((offset / 60) * 100);
>> -	return offset * eastwest;
>> +	return minutes_to_tz(offset * eastwest);
>
> While mathematically it's the same, but shouldn't this have been
> `minutes_to_tz(offset) * eastwest`?
The way you suggest is more faithful rewrite of the original.
Thanks.
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 9 of 16 in “refs/reftable: fix on-disk representation of reflog timezones”
  1. 0/3 refs/reftable: fix on-disk representation of reflog timezonesPatrick Steinhardt, Sep 29, 2026
  2. 1/3 date: add helpers to convert between "+HHMM" timezones and minutesPatrick Steinhardt, Sep 29, 2026
  3. 2/3 t/helper: fix segfault in "dump-reftable -t"Patrick Steinhardt, Sep 29, 2026
  4. 3/3 refs/reftable: fix on-disk representation of reflog timezonesPatrick Steinhardt, Sep 29, 2026
  5. Karthik NayakSep 30, 2026
  6. Karthik NayakSep 30, 2026
  7. Patrick SteinhardtSep 30, 2026
  8. Patrick SteinhardtSep 30, 2026
  9. Junio C HamanoSep 30, 2026
  10. 0/3 refs/reftable: fix on-disk representation of reflog timezonesPatrick Steinhardt, Oct 1, 2026
  11. 1/3 date: add helpers to convert between "+HHMM" timezones and minutesPatrick Steinhardt, Oct 1, 2026
  12. 2/3 t/helper: fix segfault in "dump-reftable -t"Patrick Steinhardt, Oct 1, 2026
  13. 3/3 refs/reftable: fix on-disk representation of reflog timezonesPatrick Steinhardt, Oct 1, 2026
  14. Karthik NayakOct 1, 2026
  15. Karthik NayakOct 1, 2026
  16. Junio C HamanoOct 1, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.