pike.git
/
lib
/
modules
/
Calendar.pmod
/
YMD.pike
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/lib/modules/Calendar.pmod/YMD.pike:7:
//! #pike __REAL_VERSION__ // #pragma strict_types 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); static int julian_day_from_year(int year); static int year_remaining_days(int y,int yday); static array(int) year_month_from_month(int y,int m); // [y,m,ndays,myd] static array(int) month_from_yday(int y,int yday); // [m,day-of-month,ndays,myd]
pike.git/lib/modules/Calendar.pmod/YMD.pike:637:
error("add: incompatible class %O\n", object_program(step)); } array(int(-1..1)) _compare(TimeRange with) { if (objectp(with)) if (with->is_timeofday) { // wrap
-
array(int(-1..1)) cmp=with->_compare(this
_object(
)
)
;
+
array(int(-1..1)) cmp=with->_compare(this);
return ({-cmp[0], -cmp[2], -cmp[1], -cmp[3]}); } else if (with->is_ymd || with->julian_day) { #define CMP(A,B) ( ((A)<(B))?-1:((A)>(B))?1:0 )
pike.git/lib/modules/Calendar.pmod/YMD.pike:818:
int num=mp[0]; if (num==-1 && !n) return Month("ymd_ym",rules,y,m,1); if (num<0) num+=1+number_of_months(); array(TimeRange) res=months(num,num); if (sizeof(res)==1) return res[0]; error("not in range; Month 1..%d exist in %O\n",
-
number_of_months(),this
_object(
)
)
;
+
number_of_months(),this);
} //---- week int number_of_weeks(); array(cWeek) weeks(int ...range) { int from=1,n=number_of_weeks(),to=n;
pike.git/lib/modules/Calendar.pmod/YMD.pike:1182:
TimeRange _move(int m,YMD step) { if (!step->n || !m) return this; if (step->is_year) return Year("ymd_yn",rules,y+m*step->n,n) ->autopromote(); if (step->is_month)
-
return month()->add(m,step)->set_size(this
_object(
)
)
;
+
return month()->add(m,step)->set_size(this);
// if (step->is_week)
-
// return week()->add(m,step)->set_size(this
_object(
)
)
;
+
// return week()->add(m,step)->set_size(this);
if (step->is_ymd) return Day("ymd_jd",rules, yjd+m*step->number_of_days(),number_of_days()) ->autopromote(); error("_move: Incompatible type %O\n",step); } static void convert_from(TimeRange other)
pike.git/lib/modules/Calendar.pmod/YMD.pike:1285:
//! from <ref to=YMD.month>YMD</ref>(). cMonth month(int|string ... mp) { if (sizeof(mp) && stringp(mp[0])) { int num=((int)mp[0]) || rules->language[f_month_number_from_name](mp[0]); if (!num)
-
error("no such month %O in %O\n",mp[0],this
_object(
)
)
;
+
error("no such month %O in %O\n",mp[0],this);
return ::month(num); } else return ::month(@mp); } //! method Week week() //! method Week week(int n) //! method Week week(string name)
pike.git/lib/modules/Calendar.pmod/YMD.pike:1822:
n=0; } TimeRange _move(int x,YMD step) { if (step->is_week) return Week("ymd_yw",rules,y,w+x*step->n,n) ->autopromote(); if (step->is_year)
-
return year()->add(x,step)->place(this
_object()
,1);
+
return year()->add(x,step)->place(this,1);
if (step->number_of_days) return Day("ymd_jd",rules, jd+x*step->number_of_days(),number_of_days()) ->autopromote(); error("add: Incompatible type %O\n",step); } TimeRange place_day(int day,int day_n,int force)
pike.git/lib/modules/Calendar.pmod/YMD.pike:1914:
//! the weekday-from-string routine is language dependent. cDay day(int|string ... mp) { if (sizeof(mp) && stringp(mp[0])) { int num=((int)mp[0]) || rules->language[f_week_day_number_from_name](mp[0]); if (!num)
-
error("no such day %O in %O\n",mp[0],this
_object(
)
)
;
+
error("no such day %O in %O\n",mp[0],this);
return ::day(num); } else return ::day(@mp); } cWeek set_ruleset(.Ruleset r) { return Week("ymd_yjwm",r,y,yjd,jd,w,n,md,m,mnd);
pike.git/lib/modules/Calendar.pmod/YMD.pike:2146:
n=other->number_of_days(); else n=0; } // --- Day _move static TimeRange _move(int x,YMD step) { if (step->is_year)
-
return year()->add(x,step)->place(this
_object()
,1);
+
return year()->add(x,step)->place(this,1);
if (step->is_month)
-
return month()->add(x,step)->place(this
_object()
,1);
+
return month()->add(x,step)->place(this,1);
if (step->is_week)
-
return week()->add(x,step)->place(this
_object()
,1);
+
return week()->add(x,step)->place(this,1);
if (step->is_day) return Day("ymd_jd",rules,jd+x*step->n,n) ->autopromote(); error("_move: Incompatible type %O\n",step); } TimeRange place(TimeRange what,int|void force) {
pike.git/lib/modules/Calendar.pmod/YMD.pike:2193:
// werror("%O %O\n",u0,u1); if (u1-u0) res=res->add(u1-u0,Second); else res=res->autopromote(); if (!force) { if (res->hour_no()!=what->hour_no()) error("place: no such time of "
-
"day (DST shift)\n",what,this
_object(
)
)
;
+
"day (DST shift)\n",what,this);
} } else res=res->autopromote(); return res; } if (what->is_year) return year()->place(what,force); // just fallback
pike.git/lib/modules/Calendar.pmod/YMD.pike:2629:
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;
// #define NOCATCH #ifndef NOCATCH if (catch { #else werror("%O\n",m); #endif if (m->n && m->n!="") return 0;