'stardate' functions

```-- 'stardate' functions: requested by Joseph Martin
-- kwisoft (c) 1997

global constant MONTHS  = {"January","February","March","April","May","June",
"July","August","September","October","November","December"}

-- SNIP -<code I found somewhere; sorry to the poster; I don't know who it was>
global function isyearleap(integer year)
--  Returns 1 if year is a leap year, 0 otherwise.
--  Source:  "Practical Algorithms for Programmers"
--  By:  Andrew Binstock and John Rex
if not remainder(year,4) = 0 then       -- If year not divisible by 4
return 0                            -- it's not leap.
elsif year < 1582 then                  -- All years divisible by 4 were
return 1                            -- leap prior to 1582.
elsif remainder(year,100) != 0 then     -- If year divisible by 4,
return 1                            -- but not by 100, its leap.
elsif not remainder(year,400) = 0 then  -- If year divisible by 100,
return 0                            -- but not by 400, it's not leap.
else
return 1                            -- If divisible by 400, it's leap.
end if
end function    -- isyearleap
-- SNIP ----------------------------------------------------------------

global function day2month(integer day, integer year)
sequence result, total_days
result = {"ERROR", 0} -- display if input incorrect
total_days = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}
if isyearleap(year) then
total_days[3..13] = total_days [ 3..13]+ 1
end if
for month = 1 to 12 do
if day > total_days[month] and day <= total_days[month+1] then
result = {MONTHS[month], day - total_days[month]}
end if
end for
return result
end function    -- day2month
-------------------------------------------------------------------------------
-- test it  --
--------------

integer day, year

day = 85
year = 1997

printf(1, "Today it is %s %d, %d\n", day2month(day, year) & year)

puts(1, "\nPress a key.....\n")
while get_key() = -1 do
end while
```