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:1:
//! //! module Calendar //! submodule YMD //! //! base for all Roman-kind of Calendars, //! ie, one with years, months, weeks and days //!
+
//! inherits Time
#pike __REAL_VERSION__ // #pragma strict_types inherit Calendar.Time:Time; #include "constants.h" // ----------------
pike.git/lib/modules/Calendar.pmod/YMD.pike:144:
//! method string week_name() //! method string year_name() //! method string tzname() //! method string tzname_iso() int julian_day() { return jd; }
-
//!
function
method int unix_time()
+
//! method int unix_time()
//! Returns the unix time integer corresponding to the start //! of the time range object. (An unix time integer is UTC.) int unix_time() { // 1970-01-01 is julian day 2440588 int ux=(jd-2440588)*86400; if (utco==CALUNKNOWN) [utco,tzn]=rules->timezone->tz_jd(jd); return ux+utco;
pike.git/lib/modules/Calendar.pmod/YMD.pike:269:
return rules->language[f_week_day_shortname_from_number](wd); } int leap_year() { return year_leap_year(year_no()); } int hour_no() { return 0; } int minute_no() { return 0; } int second_no() { return 0; } float fraction_no() { return 0.0; }
-
//!
function
method datetime()
+
//! method
mapping
datetime()
//! This gives back a mapping with the relevant //! time information (representing the start of the period); //! <pre> //! ([ "year": int // year number (2000 AD=2000, 1 BC==0) //! "month": int(1..) // month of year //! "day": int(1..) // day of month //! "yearday": int(0..) // day of year //! "week": int(1..) // week of year //! "week_day": int(0..) // day of week //! "timezone": int // offset to utc, including dst
pike.git/lib/modules/Calendar.pmod/YMD.pike:1432:
} cYear set_ruleset(Calendar.Ruleset r) { return Year("ymd_y",r,y,yjd,n); } } // ----------------------------------------------------------------
-
//
Month
+
//
!
class
Month
+
//!
inherits YMD
// ---------------------------------------------------------------- function(mixed...:cMonth) Month=cMonth; class cMonth { inherit YMD; constant is_month=1; int nd; // number of days
pike.git/lib/modules/Calendar.pmod/YMD.pike:1723:
//! calendar, which modifies this rule for the Gregorian calendar; //! the week number and year is the same as for the ISO calendar, //! except for the sundays. //! //! When adding, moving and subtracting months //! to a week, it falls back to using days. //! //! When adding, moving or subtracting years, //! if tries to place the moved week in the //! resulting year.
+
//!
+
//! inherits YMD
// ---------------------------------------------------------------- function(mixed...:cWeek) Week=cWeek; class cWeek { inherit YMD; // Note: wy, w and wd are never CALUNKNOWN in this class. constant is_week=1;
pike.git/lib/modules/Calendar.pmod/YMD.pike:2061:
{ return Week("ymd_yjwm",r,y,yjd,jd,wy,w,n,md,m,mnd); } // --- needs to be defined protected int weeks_to_week(int y,int m); } // ----------------------------------------------------------------
-
//
Day
+
//
!
class
Day
+
//!
inherits YMD
// ---------------------------------------------------------------- class cDay { inherit YMD; constant is_day=1; int nw; //!
pike.git/lib/modules/Calendar.pmod/YMD.pike:2511:
//! inherits YMD //------------------------------------------------------------------------ class cHour { inherit Time::cHour; inherit YMD_Time; OVERLOAD_TIMEOFDAY; }
+
//------------------------------------------------------------------------
+
//! class Minute
+
//! inherits Time.Minute
+
//! inherits YMD
+
//------------------------------------------------------------------------
+
class cMinute { inherit Time::cMinute; inherit YMD_Time; OVERLOAD_TIMEOFDAY; }
-
+
//------------------------------------------------------------------------
+
//! class Second
+
//! inherits Time.Second
+
//! inherits YMD
+
//------------------------------------------------------------------------
+
class cSecond { inherit Time::cSecond; inherit YMD_Time; OVERLOAD_TIMEOFDAY; }
-
+
//------------------------------------------------------------------------
+
//! class Fraction
+
//! inherits Time.Fraction
+
//! inherits YMD
+
//------------------------------------------------------------------------
+
class cFraction { inherit Time::cFraction; inherit YMD_Time; OVERLOAD_TIMEOFDAY; }
-
+
//------------------------------------------------------------------------
+
//! class SuperTimeRange
+
//! inherits Time.SuperTimeRange
+
//------------------------------------------------------------------------
+
class cSuperTimeRange { inherit Time::cSuperTimeRange; array(cYear) years(int ...range) { return get_units("years",@range); } cYear year(void|int n) { return get_unit("years",n); } int number_of_years() { return num_units("years"); } array(cMonth) months(int ...range) { return get_units("months",@range); } cMonth month(void|int n) { return get_unit("months",n); }
pike.git/lib/modules/Calendar.pmod/YMD.pike:2584:
string format_iso_week_short() { return RBASE->format_iso_week_short(); } string format_week() { return RBASE->format_week(); } string format_week_short() { return RBASE->format_week_short(); } string format_month() { return RBASE->format_month(); } string format_month_short() { return RBASE->format_month_short(); } #undef RBASE } //------------------------------------------------------------------------
-
//! global
convinience
functions
+
//
Pop out doc-extractor context to the top-level scope.
+
//
!
module Calendar
+
//! submodule YMD
+
//
global
convenience
functions
//------------------------------------------------------------------------ //! method TimeRange parse(string fmt,string arg) //! parse a date, create relevant object //! fmt is in the format "abc%xdef..." //! where abc and def is matched, and %x is //! one of those time units: //! <pre> //! %Y absolute year //! %y dwim year (70-99 is 1970-1999, 0-69 is 2000-2069)
pike.git/lib/modules/Calendar.pmod/YMD.pike:2939:
if (sub_second) low = low->fraction(sub_second); return low; #ifndef NOCATCH }) #endif return 0; }
-
//!
function
Day dwim_day(string date)
-
//!
function
Day dwim_day(string date,TimeRange context)
+
//!
method
Day dwim_day(string date)
+
//!
method
Day dwim_day(string date,TimeRange context)
//! Tries a number of different formats on the given date (in order): //! <pre> //! <ref>parse</ref> format as in //! "%y-%M-%D (%M) -W%W-%e (%e)" "2000-03-20 (Mar) -W12-1 (Mon)" //! "%y-%M-%D" "2000-03-20", "00-03-20" //! "%M%/%D/%y" "3/20/2000" //! "%D%*[ /]%M%*[ /-,]%y" "20/3/2000" "20 mar 2000" "20/3 -00" //! "%e%*[ ]%D%*[ /]%M%*[ /-,]%y" "Mon 20 Mar 2000" "Mon 20/3 2000" //! "-%y%*[ /]%D%*[ /]%M" "-00 20/3" "-00 20 mar" //! "-%y%*[ /]%M%*[ /]%D" "-00 3/20" "-00 march 20"
pike.git/lib/modules/Calendar.pmod/YMD.pike:3170:
(t=parse(rfc850_date, what, cx)) || (t=parse(asctime_date+" %z", what+" GMT", cx)) ) return t; return 0; } //-- auxillary functions------------------------------------------------ //!
-
//! function datetime(int|void unix_time)
+
//! function
mapping(string:int)
datetime(int|void unix_time)
//! Replacement for localtime; gives back a mapping: //! <pre> //! ([ "year": int // year number (2000 AD=2000, 1 BC==0) //! "month": int(1..) // month of year //! "day": int(1..) // day of month //! "yearday": int(1..) // day of year //! "week": int(1..) // week of year //! "week_day": int(1..) // day of week (depending on calendar) //! "unix": int // unix time //! "julian": float // julian day //! "hour": int(0..) // hour of day, including dst //! "minute": int(0..59) // minute of hour //! "second": int(0..59) // second of minute //! "fraction": float // fraction of second //! "timezone": int // offset to utc, including dst //! ]); //! </pre> //! This is the same as calling <ref>Second</ref>()-><ref to=Second.datetime>datetime</ref>(). //!
-
//! function datetime_name(int|void unix_time)
-
//! function datetime_short_name(int|void unix_time)
+
//! function
string
datetime_name(int|void unix_time)
+
//! function
string
datetime_short_name(int|void unix_time)
//! Compat functions; same as <ref>format_iso</ref> //! and <ref>format_iso_short</ref>. //! //! function string format_iso(void|int unix_time) //! function string format_iso_short(void|int unix_time) //! function string format_iso_tod(void|int unix_time) //! function string format_day_iso(void|int unix_time) //! function string format_day_iso_short(void|int unix_time) //! Format the object into nice strings; //! <pre>