/*-------------------------------------------------------* * Simple clock epplet * * by Brendon Davidson * * Thanks to Brian Mattern for helping me understand * * how epplets work. * *-------------------------------------------------------*/ uses String, Time; /* global vars */ global { object epp; object dateObj; string theDay = ""; } /* function to update time display */ function time_update(object data, number val){ string date = Time.ctime(Time.time()); string month = String.copySection(date,4,7); string day = String.copySection(date,8,10); string year = String.copySection(date,20,24); string time = String.copySection(date,11,20); number hour = String.toLong(String.copySection(time,0,2)); string min = String.copySection(time,3,5); string seconds = String.copySection(time,6,8); string timeofday = "AM"; if(hour>12||hour==12){ timeofday = "PM"; hour = hour - 12; } if(hour==0) hour = 12; /* Is it time to update the date? */ if(day!=theDay){ theDay = day; switch(month){ case "Jan": month = "January"; break; case "Feb": month = "February"; break; case "Mar": month = "March"; break; case "Apr": month = "April"; break; case "Jun": month = "June"; break; case "Jul": month = "July"; break; case "Aug": month = "August"; break; case "Sep": month = "September"; break; case "Oct": month = "October"; break; case "Nov": month = "November"; break; case "Dec": month = "December"; break; } dateObj.setText("$month $day, $year"); } data.setText("$hour:$min:$seconds $timeofday"); epp.addTimer("clockTimer",0.5,"time_update",0,data); } /* main function */ /* declare vars */ object timeObj; object backgroundObj; /* create a new epplet */ epp = new Epplet(); epp.resize(100, 30); /* create background image object for clock */ backgroundObj = new EvasObject(epp); backgroundObj.addImage(epp.getEppletDir()+"clock.png"); backgroundObj.move(epp.getX(),epp.getY()); backgroundObj.setLayer(9998); backgroundObj.show(); /* create text object for clock display */ timeObj = new EvasObject(epp); timeObj.addText("borzoib",8,""); timeObj.move(epp.getX()+epp.getW()-33, epp.getY()+6); timeObj.setLayer(9999); timeObj.setColor(0,0,0,140); timeObj.show(); /* create text object for date display */ dateObj = new EvasObject(epp); dateObj.addText("borzoib",8,""); dateObj.move(epp.getX()+epp.getW()-60,epp.getY()+35); dateObj.setLayer(9999); dateObj.setColor(0,0,0,140); dateObj.show(); /* update clock display */ time_update(timeObj,0);