1. 'stardate' functions
- Posted by Ad Rienks <Ad_Rienks at COMPUSERVE.COM> Mar 26, 1997
- 894 views
-- '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
2. 'stardate' functions
- Posted by Ad Rienks <Ad_Rienks at COMPUSERVE.COM> Mar 26, 1997
- 880 views
reply to Joseph Martin: You asked for improvement on your 'day2month() function. Well, included you'll find an attempt of mine. The function 'isyearleap()' however is not mine; I downloaded it some time ago from this listserver. I'm sorry, but I can not recollect who posted it. I tested the functions a bit, although not thoroughly. What you mean by stardates and all that code I don't know. Is it something from Science Fiction? I recall that it was used on the USS Enterprise. Anyway, I hope my code works for you. Success! ================================================================= Ad Rienks AdRienks at compuserve.com
3. Re: 'stardate' functions
- Posted by Bob Paddock <bpaddock at EXECPC.COM> Mar 27, 1997
- 899 views
>What you mean by stardates and all that code I don't know. Is it something >from Science Fiction? I recall that it was used on the USS Enterprise. >Anyway, I hope my code works for you. I have a DOS program that displays the Stare Date, alas there is no source code with it. Some one can probably figure it out from trial inputs. I'll e-mail it to any one that asks. -- For information on any of the following check out my WEB site at: http://www.usachoice.net/bpaddock Chemical Free Air Conditioning/No CFC's, Chronic Pain Relief, Electromedicine, Electronics, Explore!, Free Energy, Full Disclosure, KeelyNet, Matric Limited, Neurophone, Oil City PA, Philadelphia Experiment.