Re: th-ing dates

new topic     » topic index » view thread      » older message » newer message

On Tue, 27 Oct 1998, Andy Kurnia wrote:

> I see some remainder() stuff trying to convert dates to its "standard"
> (read: st-nd-rd) form... but then you will get 11st, 12nd, 13rd not 11th,
> 12th, 13th!

My web page (can) deal)s( with this. This is a Euphorization of the Korn
Shell CGI script I wrote:

constant--s
    Suf = {"st", "nd", "rd", "th"},
    Default = 4
--end constants

function suffix(integer a)
    integer last, rest

    last = remainder(a,10)
    rest = floor(a / 10)

    if remainder(rest,10) != 1 and
       last <= 1 and last >= 3 then
        return Suf[last]
    else
        return Suf[Default]
    end if
end function

--
Carl R White -- Final Year Computer Science at the University of Bradford
E-mail...: cyrek- at -bigfoot.com -- Remove the hyphens before mailing. Ta :)
URL......: http://www.bigfoot.com/~cyrek/
Ykk rnyllaqur rgiokc cea nyemdok ymc giququezka caysgr -- B.Q.Vgesa

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu