The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: random832@fastmail.com (Random832)
Subject: [TUHS] Date madness
Date: Wed, 13 Dec 2017 22:07:35 -0500	[thread overview]
Message-ID: <1513220855.2223106.1204498584.3CB1C63A@webmail.messagingengine.com> (raw)
In-Reply-To: <201712131912.vBDJCb3a120561@tahoe.cs.Dartmouth.EDU>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1954 bytes --]

On Wed, Dec 13, 2017, at 14:12, Doug McIlroy wrote:
> >  Flipping it to unsigned int was the quickest way out to kick the can until Sun Feb 6 06:28:15 2106.  If you have source it’s incredibly trivial to change, and nothing changes size wise.
> 
> Easy, but perhaps unwise. The sign bit is a potential escape hatch for
> times, just as it is for characters in UTF-8.
> 
> Doug

I'm not sure what you're suggesting - UTF-8 works because it's a
variable length encoding - a variable length timestamp might be
interesting as an academic exercise, but there's no way for time() to
specify how much space is needed, or be informed of how much space is
allocated

Anyway, making it use an "unsigned" 32-bit value is a bit less trivial
on V7 (where AIUI there's an unsigned type and a long type, but not
both), but the following works - not tested on actual V7 yet, but works
with the values as int16_t/int32_t on a modern system

        /*
         * break initial number into days
         */
        hms = *tim % 86400;
        day = *tim / 86400;
        if(*tim < 0) {
            hms += 109696;
            day += 49709 + hms / 86400;
            hms %= 86400;
        }

47909 days + 109696 seconds = 2^32 seconds. The "extra day" is to ensure
hms is positive.

This is instead of the existing hms < 0 clause

Making V6 do it (no long *or* unsigned type) is a bit more involved, but
I'm close to something viable. Incidentally, one gotcha I've run into is
that the code as-is passes the year minus 1900 to dysize, whereas modern
dysize implementations that respect the 100 and 400 year rules require
the full year.

My current attempt to extend it to more bits without resorting to
floating point relies on the fact that 86400=675*128 to eke out an extra
seven bits without implementing a general purpose division algorithm,
which gets it as far as the year ~10680 (~19391 unsigned). Though
without a long for the day count, V6 can only get to 2149.


  reply	other threads:[~2017-12-14  3:07 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-13 19:12 Doug McIlroy
2017-12-14  3:07 ` Random832 [this message]
2017-12-15  3:04   ` Random832
  -- strict thread matches above, loose matches on Subject: below --
2017-12-16 10:50 Doug McIlroy
2017-12-16 16:11 ` Random832
2017-12-16 17:11   ` Ralph Corderoy
2017-12-13 22:16 Norman Wilson
2017-12-14  0:24 ` Chris Torek
2017-12-17 16:20   ` Ron Natalie
2017-12-17 18:53     ` Tom Ivar Helbekkmo
2017-12-17 20:07       ` Ron Natalie
2017-12-13 20:22 Noel Chiappa
2017-12-13 17:16 Noel Chiappa
2017-12-13 18:53 ` Tom Ivar Helbekkmo
2017-12-13 20:46 ` arnold
2017-12-15 16:41   ` Paul Winalski
2017-12-15 17:19     ` Dave Horsfall
2017-12-16 15:45     ` Clem Cole
2017-12-16  3:39   ` Dave Horsfall
2017-12-16  3:45     ` Lyndon Nerenberg
2017-12-17  1:43       ` Dave Horsfall
2017-12-14  3:08 ` Dave Horsfall
2017-12-14  3:13   ` Warner Losh
2017-12-13 16:31 Noel Chiappa
2017-12-13 16:50 ` arnold
2017-12-13 16:08 Noel Chiappa
2017-12-13 16:23 ` arnold
2017-12-13 15:56 Noel Chiappa
2017-12-12 18:31 Noel Chiappa
2017-12-12 18:01 Noel Chiappa
2017-12-12 18:21 ` Warner Losh
2017-12-13 15:07 ` Random832
2017-12-13 17:00   ` Jason Stevens
2017-12-13 17:18     ` Ron Natalie
2017-12-13 18:02       ` Arthur Krewat
2017-12-13 15:39 ` Wolfgang Helbig
2017-12-14  0:57 ` Dave Horsfall
2017-12-14 14:09   ` William Cheswick
2017-12-17 16:19     ` Ron Natalie
2017-12-17 16:33       ` William Cheswick
2017-12-17 17:54         ` Random832
2017-12-17 22:15           ` Dave Horsfall
2017-12-17 22:54             ` Ian Zimmerman
2017-12-16 18:12 ` Wolfgang Helbig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1513220855.2223106.1204498584.3CB1C63A@webmail.messagingengine.com \
    --to=random832@fastmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).