Additional analysis of `rlog -zLT` bug
--------------------------------------

The incorrect +3h shift for `-zLT` is caused by the implementation
of `rcs_set_tz()` in `src/usr.bin/rcs/rcstime.c <http://usr.bin/rcs/rcstime.c>`.

Current code path:

    now = mktime(&rdp->rd_date);
    ltb = localtime(&now);
    ltb->tm_hour += ((int)ltb->tm_gmtoff/3600);
    memcpy(tb, ltb, sizeof(*tb));

This applies the offset twice:
  1. `mktime()` interprets `rd_date` as localtime, not UTC
     (RCS stores UTC).
  2. `localtime()` then applies DST again.
  3. Finally, `tm_gmtoff` is added manually a second time.

Result: time is shifted by +3h, while `%z` still prints +0200.

---

Suggested fix:

For `-zLT` use `timegm(3)` and `localtime_r()` only,
without any manual adjustment:

```diff
--- rcstime.c.orig
+++ rcstime.c
@@ -19,10 +19,11 @@
-       now = mktime(&rdp->rd_date);
-       ltb = localtime(&now);
-       ltb->tm_hour += ((int)ltb->tm_gmtoff/3600);
-       memcpy(tb, ltb, sizeof(*tb));
+       /* rd_date is stored in UTC. Convert with timegm()
+        * and let localtime() apply the correct offset/DST. */
+       now = timegm(&rdp->rd_date);
+       ltb = localtime(&now);
+       memcpy(tb, ltb, sizeof(*tb));

Reply via email to