Re: Date and time program
- Posted by irv at ELLIJAY.COM Sep 25, 1998
- 456 views
On Fri, 25 Sep 1998 13:58:28 -0400, Matt Z Nunyabidness <matt1421 at JUNO.COM> wrote: >Here. Dt.ex: <snip> No offense intended; your code works fine. Just for comparison, a more Euphorish way to write it might be: include graphics.e include file.e constant YEAR = 1, MONTH = 2, DAY = 3, HOUR = 4, MIN = 5, SEC = 6, DOW = 7 sequence dt, ampm, days, months days = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"} months = {"January","February","March","April","May","June", "July","August","September","October","November","December"} atom sec, -- holds previous sec hour clear_screen() sec = 0 while get_key() = -1 do dt = date() if dt[SEC] != sec then -- wait for next 1 second update for i = 1 to 7 do -- print days of the week position(1,i*4-3) if i = dt[DOW] then -- print today in another color text_color(YELLOW) else text_color(RED) end if puts(1,days[i]) end for if dt[HOUR] > 12 then ampm=" pm" hour = dt[HOUR] - 12 else ampm=" am" hour = dt[HOUR] end if text_color(BRIGHT_WHITE) position(2,1) printf(1,"%s %02d, %d",{months[dt[MONTH]],dt[DAY],dt[YEAR]+1900}) -- in year 2000, dt[YEAR] will be 100, so you can't just use -- a format string beginning with 19__ text_color(CYAN) position(3,1) printf(1,"%02d:%02d:%02d%s",{hour,dt[MIN],dt[SEC],ampm}) sec = dt[SEC] -- update the seconds end if end while