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

version» Context lines:

pike.git/lib/modules/Calendar.pmod/YMD.pike:3:   //! submodule YMD   //!   //! base for all Roman-kind of Calendars,   //! ie, one with years, months, weeks and days   //!      #pike __REAL_VERSION__      // #pragma strict_types    - import "."; - inherit Time:Time; + inherit .Time:Time;      #include "constants.h"      #define this this_object()      // ----------------   // virtual methods to tell how this calendar works   // ----------------      static array(int) year_from_julian_day(int jd);
pike.git/lib/modules/Calendar.pmod/YMD.pike:71:    int wy; // [*] week year    int w; // [*] week of week year (1..)    int wd; // [*] day of week (1..7?)       int mnd=CALUNKNOWN; // days in current month    int utco=CALUNKNOWN; // [*] distance to UTC    string tzn=0; // timezone name      // // ^^^ might be uninitialized (CALUNKNOWN)    -  Ruleset rules; +  .Ruleset rules;    constant is_ymd=1;      // ----------------------------------------   // basic Y-M-D stuff   // ----------------------------------------       void create_now()    {    rules=default_rules;    create_unixtime_default(time());
pike.git/lib/modules/Calendar.pmod/YMD.pike:1313:    sscanf(mp[0],"w%d",num);       cWeek w=::week(num);    if (w->week_no()==num) return w;    return ::week(num-(w->week_no()-num));    }    else    return ::week(@mp);    }    -  cYear set_ruleset(Ruleset r) +  cYear set_ruleset(.Ruleset r)    {    return Year("ymd_y",r,y,yjd,n);    }   }         // ----------------------------------------------------------------   // Month   // ----------------------------------------------------------------   
pike.git/lib/modules/Calendar.pmod/YMD.pike:1573:    Week("julian_r",jd,rules)    ->range(Week("julian_r",julian_day_from_year(y2)+yd2-2,rules))    ->number_of_weeks();    }       int number_of_months()    {    return n;    }    -  cMonth set_ruleset(Ruleset r) +  cMonth set_ruleset(.Ruleset r)    {    return Month("ymd_yjmw",r,y,yjd,jd,m,n,wd,w);    }      // --- needs to be defined       static int months_to_month(int y,int m);   }      // ----------------------------------------------------------------
pike.git/lib/modules/Calendar.pmod/YMD.pike:1907:    rules->language[f_week_day_number_from_name](mp[0]);    if (!num)    error("no such day %O in %O\n",mp[0],this_object());       return ::day(num);    }    else    return ::day(@mp);    }    -  cWeek set_ruleset(Ruleset r) +  cWeek set_ruleset(.Ruleset r)    {    return Week("ymd_yjwm",r,y,yjd,jd,w,n,md,m,mnd);    }      // --- needs to be defined       static int weeks_to_week(int y,int m);   }      // ----------------------------------------------------------------
pike.git/lib/modules/Calendar.pmod/YMD.pike:2243:    if (nw!=CALUNKNOWN) return nw;       if (n<=1) return nw=1;       return nw=    Week("julian_r",jd,rules)    ->range(Week("julian_r",jd+n-1,rules))    ->number_of_weeks();    }    -  cDay set_ruleset(Ruleset r) +  cDay set_ruleset(.Ruleset r)    {    return Day("ymd_ydmw",r,y,yjd,jd,yd,n,m,md,w,wd,mnd);    }      // backwards compatible with calendar I    string iso_name() { return format_ymd(); }    string iso_short_name() { return format_ymd_short(); }   }      function(mixed...:cDay) Day=cDay;
pike.git/lib/modules/Calendar.pmod/YMD.pike:2500:    if (tr->minute_no()!=m)    tr=tr->add(m-tr->minute_no(),Minute);    if (tr->second_no()!=s)    tr=tr->add(s-tr->second_no(),Second);    if (tr->hour_no()!=h || tr->minute_no()!=m ||    tr->second_no()!=s) return 0; // no such hour    }    return tr;   }    + static mapping abbr2zones; +    // dwim timezone and call dwim time of day above   // this API may change without further notice   static TimeRange dwim_zone(TimeRange origin,string zonename,    string whut,int ...args)   {    if (zonename=="") return 0;       if (zonename[0]=='"') sscanf(zonename,"\"%s\"",zonename);    sscanf(zonename,"%*[ \t]%s",zonename);       // Ugly fix for synonyms. This suppport should of course be    // added in a lower layer when the next refactoring occurs.    zonename = ([ "MEST":"CET", "MESZ":"CET" ])[zonename] || zonename;       if (origin->rules->abbr2zone[zonename])    zonename=origin->rules->abbr2zone[zonename];    -  Rule.Timezone zone=Timezone[zonename]; +  .Rule.Timezone zone=.Timezone[zonename];    if (!zone)    {    if (sscanf(zonename,"%[^-+]%s",string a,string b)==2 && a!="" && b!="")    {    TimeRange tr=dwim_zone(origin,a,whut,@args);    if (!tr) return 0;       return    dwim_tod(origin->set_timezone( -  Timezone.make_new_timezone( +  .Timezone.make_new_timezone(    tr->timezone(), -  Timezone.decode_timeskew(b))), +  .Timezone.decode_timeskew(b))),    whut,@args);    } -  -  array pz=TZnames.abbr2zones[zonename]; +  if(!abbr2zones) +  abbr2zones = master()->resolv("Calendar")["TZnames"]["abbr2zones"]; +  array pz=abbr2zones[zonename];    if (!pz) return 0;    foreach (pz,string zn)    {    TimeRange try=dwim_zone(origin,zn,whut,@args);    if (try && try->tzname()==zonename) return try;    }    return 0;    }    else    return dwim_tod(origin->set_timezone(zone),whut,@args);
pike.git/lib/modules/Calendar.pmod/YMD.pike:2600:    mapping m=mkmapping(q,res);    if (i!=-1 && m->n!="") return 0;      // werror("%O\n",m);      // werror("bopa %O\n %O\n %O\n %O\n",fmt,arg,nfmt,m);          TimeRange low;    -  Calendar cal=this_object(); +  .Calendar cal=this_object();         // #define NOCATCH   #ifndef NOCATCH    if (catch {   #else    werror("%O\n",m);   #endif    if (m->n && m->n!="") return 0;