Monday, November 08, 2010 at 12:04 AM.
system.verbs.builtins.mainResponder.calendar.getMostRecentDay
on getMostRecentDay (adrCalendar, d=clock.now ()) { <<Tue, May 23, 2000 at 5:45:17 PM by AR <<Old code <<on getMostRecentDay (adrCalendar, d=clock.now ()) <<Notes <<Thu, 11 Mar 1999 20:10:01 GMT by AR <<adrcalendar is the address of a valid calendar structure. <<d is an optional date which defaults to clock.now (). <<If the address corresponding to d exists, we return the date. <<Otherwise we walk backwards in time until we find an element and return the corresponding date. <<We throw a scriptError if the calendar does not contain elements corresponding to times before d or if adrcalendar does not point to a valid non-empty calendar structure. <<local (adrDay, dmin = mainResponder.calendar.getFirstDay (adrCalendar)) <<while (dmin <= d) <<try <<adrDay = mainResponder.calendar.getDayAddress (adrCalendar, d, flcreate:false) <<if defined (adrDay^) <<local (day, month, year, hour, minute, second) <<date.get (d, @day, @month, @year, @hour, @minute, @second) <<d = date.set (day, month, year, 0, 0, 0) <<return (d) <<d = date.yesterday (d) <<scripterror ("Can't get the most recent day in the calendar because the calendar doesn't contain any elements before " + d + ".") kernel (mrcalendar.getmostrecentday)} <<bundle //test code <<dialog.notify (getMostRecentDay (@scriptingNews))
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.