Re: [nmh-workers] Ordinal Indicators.

2019-07-09 Thread Ralph Corderoy
Hi Valdis, > > Is -42nd handled? > > I admit being totally mystified as to what situations require proper > handling of negative ordinals Well, from here the one after next is the 2nd, and the one before last is the -2nd. Regardless, the code and documentation should match, and it seems

Re: [nmh-workers] Ordinal Indicators.

2019-07-08 Thread Valdis Klētnieks
On Mon, 08 Jul 2019 17:25:42 +0100, Ralph Corderoy said: > Is -42nd handled? I admit being totally mystified as to what situations require proper handling of negative ordinals pgpM4SES7TBLk.pgp Description: PGP signature -- nmh-workers https://lists.nongnu.org/mailman/listinfo/nmh-workers

Re: [nmh-workers] Ordinal Indicators.

2019-07-08 Thread Ken Hornstein
>Is -42nd handled? You know where the source code is, Ralph. Have at it. --Ken -- nmh-workers https://lists.nongnu.org/mailman/listinfo/nmh-workers

Re: [nmh-workers] Ordinal Indicators.

2019-07-08 Thread Ralph Corderoy
Hi, Is -42nd handled? IIRC we demand C99 so we know rounding is towards zero. But C's remainder operator, ‘%’, returns the sign of the dividend, unlike modulo. And then there's two's complement so INT_MIN can't be made positive. $ for a in ' -' ' '; do > for b in ' -' ' '; do

Re: [nmh-workers] Ordinal Indicators.

2019-07-08 Thread Ralph Corderoy
> Geez, you could have just SAID that Now where would be the fun in that. :-) -- Cheers, Ralph. -- nmh-workers https://lists.nongnu.org/mailman/listinfo/nmh-workers

Re: [nmh-workers] Ordinal Indicators.

2019-07-08 Thread Ken Hornstein
>The point is, that if you're going to add this, you should do it >correctly, not just any random code that looks close. Geez, you could have just SAID that (ok, fine, you DID say that, but ... oh, never mind). I missed that part in your examples. Anyway, fixed! --Ken -- nmh-workers

Re: [nmh-workers] Ordinal Indicators.

2019-07-08 Thread Robert Elz
Ken, Ralph is being overly subtle (or perhaps I could use another word...) The point is, that if you're going to add this, you should do it correctly, not just any random code that looks close. kre ps: Hint: 11st is not correct. -- nmh-workers

Re: [nmh-workers] Ordinal Indicators.

2019-07-08 Thread Ralph Corderoy
Hi Ken, > > Were you paying attention to kre's sh and my sed? :-) > > I mean ... yeah? Steal from the best, and all that! I had a few free > minutes, I thought, "Oh, huh, nmh SHOULD have a function to output the > ordinal string for dates and such", and I though it should be pretty > easy and

Re: [nmh-workers] Ordinal Indicators.

2019-07-08 Thread Ken Hornstein
>Were you paying attention to kre's sh and my sed? :-) I mean ... yeah? Steal from the best, and all that! I had a few free minutes, I thought, "Oh, huh, nmh SHOULD have a function to output the ordinal string for dates and such", and I though it should be pretty easy and it was. --Ken --

Re: [nmh-workers] Ordinal Indicators.

2019-07-08 Thread Ralph Corderoy
Hi Ken, > > This is true. To correct that, I note mh-format(5) too has no > > function to produce the ordinal suffix. :-) > > Fixed. Impressively quick work. + int digit = value % 10; + const char *suffix; + + switch (digit) { +

Re: [nmh-workers] Ordinal Indicators.

2019-07-08 Thread Ken Hornstein
>This is true. To correct that, I note mh-format(5) too has no function >to produce the ordinal suffix. :-) Fixed. --Ken -- nmh-workers https://lists.nongnu.org/mailman/listinfo/nmh-workers

Re: [nmh-workers] Ordinal Indicators.

2019-07-08 Thread Ralph Corderoy
Hi kre, > D=$(date +%d) > case "$D" in > [023]1) ORD=st;; > [02]2) ORD=nd;; > [02]3) ORD=rd;; > *) ORD=th;; > esac > case "$D" in > 0*) SP=;; > *) SP=' ';; > esac I ended up with $ cat ~/bin/ordsuff #!

Re: [nmh-workers] Ordinal Indicators.

2019-07-08 Thread Robert Elz
Date:Mon, 08 Jul 2019 11:37:10 +0100 From:Ralph Corderoy Message-ID: <20190708103710.86f3121...@orac.inputplus.co.uk> | I had a need today to have date(1) produce 8th for today Yes, strftime() has no ordinals, and (as best I understand it) locales don't either.

Re: [nmh-workers] Ordinal Indicators.

2019-07-08 Thread Ralph Corderoy
Hi kre, > LC_TIME says how time (of day) is represented (d/m/y m/d/y, 12 or 24 > hour, etc) I had a need today to have date(1) produce ‘8th’ for today and find its interpreted sequences don't support the https://en.wikipedia.org/wiki/Ordinal_indicator, but then neither does POSIX's LC_TIME, it