)]}'
{
  "commit": "c17b2d9f6b5a4d1194e0a0f9751fb3dfb565d6e4",
  "tree": "bbf3e07995c3d314a34944ad0125beb723b92ca4",
  "parents": [
    "a018953688f1b10bddf91bff8747068f5f4746a4"
  ],
  "author": {
    "name": "Patrick Steinhardt",
    "email": "ps@pks.im",
    "time": "Thu Oct 01 07:39:00 2026 +0200"
  },
  "committer": {
    "name": "Junio C Hamano",
    "email": "gitster@pobox.com",
    "time": "Thu Oct 01 06:38:46 2026 -0700"
  },
  "message": "date: add helpers to convert between \"+HHMM\" timezones and minutes\n\nThe timezones that we store in commits as part of the identity\ninformation are encoded in \"[+-]HHMM\", for example \"-0700\" for UTC-7.\nInternally we typically pass around this timezone either as string or as\na parsed integer (-700).\n\nSome sites want to convert between this format and minutes or vice\nversa, and that conversion is performed ad-hoc. We\u0027re about to introduce\nanother site though that wants to have access to this logic, and having\nit cluttered across our codebase is a bit awkward.\n\nIntroduce two new helpers `tz_to_minutes()` and `minutes_to_tz()` that\nperform the conversion for us and convert call sites to use them.\n\nNote that we used to perform a dance in `gm_time_t()` where we first\nconvert `tz` into a positive value, then calculate the minutes, and\nfinally turn the minutes into a negative value again. This dance is\nperformed because it is implementation-defined in C89 whether the\ndivision on negative values truncates towards zero or not [1]:\n\n  If either operand is negative, whether the result of the / operator is\n  the largest integer less than the algebraic quotient or the smallest\n  integer greater than the algebraic quotient is implementation-defined,\n  as is the sign of the result of the % operator.\n\nSo under C89, `-130 / 100` could legitimately result in -1 or -2, and\n`-130 % 100` could result in either -30 or 70. For us though, the result\nthat we want is the first one (-1 and -30), which is called truncation\ntoward zero.\n\nThis part of the C language has changed in C99, where this edge case is\nnow well-defined to always truncate towards zero [2]:\n\n  When integers are divided, the result of the / operator is the\n  algebraic quotient with any fractional part discarded.90) If the\n  quotient a/b is representable, the expression (a/b)*b + a%b shall\n  equal a.\n\n  90) This is often called \u0027\u0027truncation toward zero\u0027\u0027.\n\nSo in theory it\u0027s unlikely that we still need this logic. In practice\nthough it feels safer to just retain it as we don\u0027t require a fully\nC99-compliant compiler in Git.\n\n[1]: https://port70.net/~nsz/c/c89/c89-draft.html#3.3.5\n[2]: https://port70.net/~nsz/c/c99/n1256.html#6.5.5p6\n\nSigned-off-by: Patrick Steinhardt \u003cps@pks.im\u003e\nSigned-off-by: Junio C Hamano \u003cgitster@pobox.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "f00b7ba4d3a7e6dffb50880e27c7f02df3ddcecc",
      "old_mode": 33188,
      "old_path": "apply.c",
      "new_id": "367271b8acf3668a8451f63fd2f81473c45cda1d",
      "new_mode": 33188,
      "new_path": "apply.c"
    },
    {
      "type": "modify",
      "old_id": "014065b419aee7a9f37cbb002d5155bc1a20725c",
      "old_mode": 33188,
      "old_path": "date.c",
      "new_id": "c50f45d3108a10baee65b79666ac2ce8a07c15be",
      "new_mode": 33188,
      "new_path": "date.c"
    },
    {
      "type": "modify",
      "old_id": "0747864fd71c8082dc15c0e20675a7065a83568b",
      "old_mode": 33188,
      "old_path": "date.h",
      "new_id": "816df5b83341c70dfcf300a8b06dd28544f2d260",
      "new_mode": 33188,
      "new_path": "date.h"
    },
    {
      "type": "modify",
      "old_id": "44955669e8c50413ae66e0e819502cbff59bd6e5",
      "old_mode": 33188,
      "old_path": "strbuf.c",
      "new_id": "c3baa47b3f71e727e3b7785701fb646e74f50bb9",
      "new_mode": 33188,
      "new_path": "strbuf.c"
    }
  ]
}
