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:1181:
} result += ({ start->distance(end) }); return result; } // ---------------------------------------- // virtual functions needed // ---------------------------------------- string nice_print();
-
string _sprintf(int t,mapping m)
+
protected
string _sprintf(int t,mapping m)
{ switch (t) { case 't': return "Calendar."+calendar_name()+".YMD"; default: return ::_sprintf(t,m); } }
pike.git/lib/modules/Calendar.pmod/YMD.pike:1229:
//! method void create("julian",int|float julian_day) //! method void create(int year) //! method void create(string year) //! method void create(TimeRange range) //! It's possible to create the standard year //! by using three different methods; either the normal //! way - from standard unix time or the julian day, //! and also, for more practical use, from the year number. //!
-
void create(mixed ...args)
+
protected
void create(mixed ...args)
{ if (!sizeof(args)) { create_now(); return; } else switch (args[0]) { case "ymd_y": rules=args[1];
pike.git/lib/modules/Calendar.pmod/YMD.pike:1311:
return Year("ymd_y",rules,y,yjd,0); } TimeRange end() { return Year("ymd_yn",rules,y+n,0); } // ----------------
-
string _sprintf(int t,mapping m)
+
protected
string _sprintf(int t,mapping m)
{ switch (t) { case 'O': if (n!=1) return sprintf("Year(%s)",nice_print_period()); return sprintf("Year(%s)",nice_print()); case 't': return "Calendar."+calendar_name()+".Year"; default:
pike.git/lib/modules/Calendar.pmod/YMD.pike:1540:
function(mixed...:cMonth) Month=cMonth; class cMonth { inherit YMD; constant is_month=1; int nd; // number of days int nw; // number of weeks
-
void create(mixed ...args)
+
protected
void create(mixed ...args)
{ if (!sizeof(args)) { rules=default_rules; create_unixtime_default(time()); return; } else switch (args[0]) {
pike.git/lib/modules/Calendar.pmod/YMD.pike:1618:
[y,yjd]=year_from_julian_day(jd=_jd); [m,zmd,nd,yd]=month_from_yday(y,1+jd-yjd); jd=yd+yjd-1; n=1; md=1; nw=wd=w=wy=CALUNKNOWN; // unknown } }
-
string _sprintf(int t,mapping m)
+
protected
string _sprintf(int t,mapping m)
{ // return sprintf("month y=%d yjd=%d m=%d jd=%d yd=%d n=%d nd=%d", // y,yjd,m,jd,yd,n,number_of_days()); switch (t) { case 'O': if (n!=1) return sprintf("Month(%s)",nice_print_period()); return sprintf("Month(%s)",nice_print()); case 't':
pike.git/lib/modules/Calendar.pmod/YMD.pike:1842:
//! method void create("unix",int unix_time) //! method void create("julian",int|float julian_day) //! method void create(int year,int week) //! It's possible to create the standard week //! by using three different methods; either the normal //! way - from standard unix time or the julian day, //! and also, for more practical use, from year and week //! number. //!
-
void create(mixed ...args)
+
protected
void create(mixed ...args)
{ if (!sizeof(args)) { rules=default_rules; create_unixtime_default(time()); return; } else switch (args[0]) {
pike.git/lib/modules/Calendar.pmod/YMD.pike:1925:
[wy,w,zwd,int nd,jd]=week_from_julian_day(_jd); [y,yjd]=year_from_julian_day(_jd); yd=1+jd-yjd; n=1; wd=1; md=m=CALUNKNOWN; // unknown } }
-
string _sprintf(int t,mapping m)
+
protected
string _sprintf(int t,mapping m)
{ // return sprintf("week y=%d yjd=%d w=%d jd=%d yd=%d n=%d nd=%d", // y,yjd,w,jd,yd,n,number_of_days()); switch (t) { case 'O': if (n!=1) return sprintf("Week(%s)",nice_print_period()); return sprintf("Week(%s)",nice_print()); case 't':
pike.git/lib/modules/Calendar.pmod/YMD.pike:2182:
//! method void create(int year,int month,int day) //! method void create(int year,int year_day) //! method void create(int julian_day) //! It's possible to create the day //! by using five different methods; either the normal //! way - from standard unix time or the julian day, //! and also, for more practical use, from year, month and day, //! from year and day of year, and from julian day //! without extra fuzz.
-
void create(mixed ...args)
+
protected
void create(mixed ...args)
{ if (!sizeof(args)) { rules=default_rules; create_unixtime_default(time()); return; } else switch (args[0]) {
pike.git/lib/modules/Calendar.pmod/YMD.pike:2302:
{ create_unixtime_default((int)((jd-2440588)*86400)); } else { [y,yjd]=year_from_julian_day(jd=_jd); yd=1+jd-yjd; } }
-
string _sprintf(int t,mapping m)
+
protected
string _sprintf(int t,mapping m)
{ switch (t) { case 'O': catch { if (n!=1) return sprintf("Day(%s)",nice_print_period()); return sprintf("Day(%s)",nice_print()); }; return sprintf("Day(%d)", unix_time());
pike.git/lib/modules/Calendar.pmod/YMD.pike:2818:
sscanf(zonename,"%*[ \t]%s",zonename); if(sizeof(zonename)==4 && zonename[2]=='S') zonename = zonename[0..1] + zonename[3..3]; else if(sizeof(zonename)>4 && has_suffix(zonename, "DST")) zonename = zonename[..<3]; if (origin->rules->abbr2zone[zonename]) zonename=origin->rules->abbr2zone[zonename];
-
Calendar.Rule.Timezone zone=Calendar.Timezone[zonename];
+
Calendar.Rule.Timezone zone
=
Calendar.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( Calendar.Timezone.make_new_timezone(
pike.git/lib/modules/Calendar.pmod/YMD.pike:2844:
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); } protected mapping(string:array) parse_format_cache=([]); protected mapping dwim_year=([ "past_lower":70, "past_upper":100, "current_century":2000, "past_century":1900 ]); TimeRange parse(string fmt,string arg,void|TimeRange context) {
pike.git/lib/modules/Calendar.pmod/YMD.pike:3046:
case "am": if (h==12) h=0; break; case "pm": if (h!=12) h+=12; break; default: return 0; // need "am" or "pm" } }
-
+
if (m->z) // zone low = dwim_zone(low,m->z,g,h,mi,s); else if (g) low = dwim_tod(low,g,h,mi,s); else if (!zero_type(m->S)) low = Second(m->S); if (sub_second) low = low->fraction(sub_second); return low;
pike.git/lib/modules/Calendar.pmod/YMD.pike:3267:
} error("Failed to dwim time from %O\n",what); } // Parses time according to HTTP 1.1 (RFC 2616) HTTP-date token. TimeofDay http_time(string what, void|TimeRange cx) { TimeofDay t;
-
string
date1 = "%D %M %Y"; // 2+1+3+1+4=11
-
string
date2 = "%D-%M-%y"; // 2+1+3+1+2=9
-
string
date3 = "%M %*[ ]%D"; // 2+1+2=5
-
string
time = "%h:%m:%s"; // 2+1+2+1+2=8
+
constant
date1 = "%D %M %Y"; // 2+1+3+1+4=11
+
constant
date2 = "%D-%M-%y"; // 2+1+3+1+2=9
+
constant
date3 = "%M %*[ ]%D"; // 2+1+2=5
+
constant
time = "%h:%m:%s"; // 2+1+2+1+2=8
// 3+2+ 11 +1+ 8 +4 = 29
-
string
rfc1123_date = "%e, "+date1+" "+time+" %z";
+
//
RFC 1123 (and RFC 822 which it bases its timestamp format on)
+
// supports more variations than we support here.
+
constant
rfc1123_date = "%e, "+date1+" "+time+" %z";
// 6+2+ 9 +1+ 8 +4 = 33
-
string
rfc850_date = "%e, "+date2+" "+time+" %z";
+
constant
rfc850_date = "%e, "+date2+" "+time+" %z";
// 3+1+ 5 +1+ 8 +1+4 = 23
-
string
asctime_date = "%e "+date3+" "+time+" %Y";
+
constant
asctime_date = "%e "+date3+" "+time+" %Y";
if( sizeof(what)<23 ) return 0; if( (t=parse(rfc1123_date, what, cx)) || (t=parse(rfc850_date, what, cx)) || (t=parse(asctime_date+" %z", what+" GMT", cx)) ) return t; return 0; }