pike.git / lib / modules / Calendar.pmod / Events.pmod

version» Context lines:

pike.git/lib/modules/Calendar.pmod/Events.pmod:9:   constant month2n=(["Jan":1,"Feb":2,"Mar":3,"Apr":4,"May":5,"Jun":6,    "Jul":7,"Aug":8,"Sep":9,"Oct":10,"Nov":11,"Dec":12]);   constant wd2n=(["Mon":1,"Tue":2,"Wed":3,"Thu":4,"Fri":5,"Sat":6,"Sun":7]);      void read_all_data()   {    all_data=master()->master_read_file(    combine_path(__FILE__,"../events/regional"));   }    +  + //! The Event system + //! + //! Q: How do I find out which days are red in a specific region? + //! + //! A: Events.<region> + //! + //! - contains the events for the region, as a SuperEvent. + //! You can ask this object to filter out the holidays, + //! + //! @code + //! Events.se.holidays(); + //! @endcode + //! + //! Which will be a superevent containing only holidays. + //! + //! To use this information, you can for instance use ->scan, + //! here in an example to see what red days there were in Sweden + //! in 2001 + //! + //! @code + //! > Calendar.Events.se->filter_flag("h")->scan(Calendar.Month()); + //! Result: ({ /* 6 elements */ + //! Day(Sun 7 Jan 2001), + //! Day(Sun 14 Jan 2001), + //! Day(Sun 21 Jan 2001), + //! Day(Sun 28 Jan 2001), + //! Day(Sat 6 Jan 2001), + //! Day(Mon 1 Jan 2001) + //! @endcode +    Event.Event make_event(string source)   {    string id;    string flags;    string s;    string rule;       if (sscanf(source, "%*[ \t]Event%*[ \t]"    "\"%[^\"]\"%*[ \t]%[-a-z]%*[ \t]"    "\"%s\"%*[ \t]%[^\n]",
pike.git/lib/modules/Calendar.pmod/Events.pmod:194:   }      mapping made_namedays=([]);      string read_all_namedays()   {    return master()->master_read_file(    combine_path(__FILE__,"../events/namedays"));   }    +    Event.Namedays find_namedays(string region)   {    string id="namedays/"+region;    object res;    if ( (res=made_namedays[region]) )    return res;    string all=read_all_namedays();       int i=search(all,"\nRegion \""+region+"\"");    if (i==-1) return UNDEFINED; // not found
pike.git/lib/modules/Calendar.pmod/Events.pmod:386:   }      array all_regions()   {    if (!all_data) read_all_data();    return `+(@array_sscanf(all_data,"%{%*s\nRegion \"%s\"%}")[0]);   }      // -----------------------------------------------------------------------    + //! @decl Event.Event `[](string region) + //! @decl Event.Event `->(string region) + //! + //! return the Event object for the specified region or the specified + //! named event. +    program|Event.Event `[](string s)   {    return ::`[](s) || magic_event(s);   }   program|Event.Event `-> (string s) {return `[] (s);}      // Don't load Geogrphy.Countries unless we have to   object country_lookup=0;      Event.Event|Event.Namedays magic_event(string s)