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

version» Context lines:

pike.git/lib/modules/Calendar.pmod/Time.pmod:148:    ls=CALUNKNOWN;    }       static void create_now();       void create_julian_day(int|float jd)    {   // 1970-01-01 is julian day 2440588    jd-=2440588;    float fjd=(jd-(int)jd)-0.5; -  ux=((int)jd)*86400+(int)(fjd*86400); +     ls=CALUNKNOWN; -  +  create_unixtime_default(((int)jd)*86400+(int)(fjd*86400));    }      // make base   // needed in ymd   /*static*/ TimeRange make_base()    {    base=Day("unix_r",ux,rules);    if (len) base=base->range(Day("unix_r",ux+len,rules));   // werror("make base -> %O\n",base);    return base;
pike.git/lib/modules/Calendar.pmod/Time.pmod:187:   // default autopromote    TimeRange autopromote()    {    return this_object();    }       array(int(-1..1)) _compare(TimeRange with)    {   #define CMP(A,B) ( ((A)<(B))?-1:((A)>(B))?1:0 )    +  if (!objectp(with)) +  error("_compare: illegal argument 1, expected TimeRange: %O\n",with); +     if (with->is_timeofday_f)    {    array(int(-1..1)) cmp=with->_compare(this_object());       return ({-cmp[0],    -cmp[2],    -cmp[1],    -cmp[3]});    }    else if (with->is_timeofday)
pike.git/lib/modules/Calendar.pmod/Time.pmod:285:    TimeRange _set_size(int n,TimeRange t)    {    if (!t->is_timeofday)    return distance(add(n,t));       return Second("timeofday_sd",rules,ux,n*(t->len),ls,utco)->autopromote();    }       TimeRange _move(int n,int m);    -  TimeRange _add(int n,TimeRange step) +  TimeRange _add(float|int n,TimeRange step)    {    if (step->is_timeofday_f)    return Fraction("timeofday_f",rules,ux,0,len,0)    ->add(n,step);    if (step->is_timeofday)    return _move(n,step->number_of_seconds());       if (!base) make_base();    return base->add(n,step)->place(this_object(),1);    }
pike.git/lib/modules/Calendar.pmod/Time.pmod:691:   //! method string format_ymd_xshort();   //! method string format_iso_week();   //! method string format_iso_week_short();   //! method string format_week();   //! method string format_week_short();   //! method string format_month();   //! method string format_month_short();   //! method string format_iso_time();   //! method string format_time();   //! method string format_time_short(); + //! method string format_iso_short();   //! method string format_time_xshort();   //! method string format_mtime();   //! method string format_xtime();   //! method string format_tod();   //! method string format_xtod();   //! method string format_mod();   //! method string format_nice();   //! method string format_nicez();   //! Format the object into nice strings;   //! <pre>
pike.git/lib/modules/Calendar.pmod/Time.pmod:719:   //! week_short "2000w22" [2]   //! month "2000-06"   //! month_short "200006" [1]   //! iso_time "2000-06-02 (Jun) -W22-5 (Fri) 20:53:14 UTC+1" [2]   //! ext_time "Friday, 2 June 2000, 20:53:14" [2]   //! ctime "Fri Jun 4 20:53:14 2000\n" [2] [3]   //! http "Fri, 02 Jun 2000 19:53:14 GMT" [4]   //! time "2000-06-02 20:53:14"   //! time_short "20000602 20:53:14"   //! time_xshort "000602 20:53:14" + //! iso_short "20000602T20:53:14"   //! mtime "2000-06-02 20:53"   //! xtime "2000-06-02 20:53:14.000000"   //! todz "20:53:14 CET"   //! todz_iso "20:53:14 UTC+1"   //! tod "20:53:14"   //! tod_short "205314"   //! xtod "20:53:14.000000"   //! mod "20:53"   //! nice "2 Jun 20:53", "2 Jun 2000 20:53:14" [2][5]   //! nicez "2 Jun 20:53 CET" [2][5]
pike.git/lib/modules/Calendar.pmod/Time.pmod:776:    string format_time()    {    return this_object()->format_ymd()+" "+format_tod();    }       string format_time_short()    {    return this_object()->format_ymd_short()+" "+format_tod();    }    +  string format_iso_short() +  { +  return this_object()->format_ymd_short()+"T"+format_tod(); +  } +     string format_time_xshort()    {    return this_object()->format_ymd_xshort()+" "+format_tod();    }       string format_mtime()    {    return this_object()->format_ymd()+" "+format_mod();    }   
pike.git/lib/modules/Calendar.pmod/Time.pmod:932:    return    (u<0)    ?sprintf("UTC+%d:%02d",-u/3600,(-u/60)%60)    :sprintf("UTC-%d:%02d",u/3600,(u/60)%60);    return    (u<0)    ?sprintf("UTC+%d:%02d:%02d",-u/3600,(-u/60)%60,(-u)%60)    :sprintf("UTC-%d:%02d:%02d",u/3600,(u/60)%60,u%60);    }    +  +  + // ----------------------------------------------------------------- +  +  TimeRange place(TimeRange what,void|int force) +  { +  if (!base) make_base(); +  if (what->is_ymd) +  return base->place(what,force); +  +  error("place: Incompatible type %O\n",what); +  } +    // --------      // #define TIME_OPERATOR_DEBUG   #ifdef TIME_OPERATOR_DEBUG   #define DEBUG_OVERLOAD_OPERATOR(OP,NAME,IND) \    TimeRange OP(mixed ...args) \    { \    _ind+=IND; \    TimeRange x=::OP(@args); \    _ind=_ind[..strlen(_ind)-strlen(IND)-1]; \
pike.git/lib/modules/Calendar.pmod/Time.pmod:1128:      #undef RBASE      // count parts elapsed    string format_elapsed()    {    TimeRange z=parts[0];    foreach (parts,TimeRange y) z+=y;    return parts[0]->distance(z)->format_elapsed();    } +  +  string sprintf(int t,mapping m) +  { +  if (t=='t') +  return "Calendar."+calendar_name()+".TimeofDay"; +  return ::sprintf(t,m);    } -  + }      class cNullTimeRange   {    inherit TimeRanges::cNullTimeRange;       array(cHour) hours(int ...range) { return ({}); }    cHour hour(void|int n) { error("no hours in nulltimerange\n"); }    int number_of_hours() { return 0; }       array(cMinute) minutes(int ...range) { return ({}); }
pike.git/lib/modules/Calendar.pmod/Time.pmod:1172:    void create_unixtime_default(int unixtime)    {    create_unixtime(unixtime,3600);    }       static void create_now()    {    create_unixtime(time(),3600);    }    +  static void create_unixtime(int _ux,int _len) +  { +  ::create_unixtime(_ux,_len); +  if (ls==CALUNKNOWN) make_local(); +  if (ls%3600) ux-=ls%3600,ls=CALUNKNOWN; +  } +     static void create_julian_day(int|float jd)    {    ::create_julian_day(jd);    len=3600;    }       static void convert_from(TimeRange other)    {    ::convert_from(other);    len-=len%3600;
pike.git/lib/modules/Calendar.pmod/Time.pmod:1193:       TimeofDay _move(int n,int m)    {    if (m==0 || n==0) return this_object();    if (m%3600)    return Second("timeofday",rules,ux,len)->_move(n,m);    return Hour("timeofday",rules,ux+n*m,len)->autopromote();    }       -  string _sprintf(int t) +  string _sprintf(int t,mapping m)    {    if (catch {    switch (t)    {    case 'O':    if (!base) make_base();    if (len!=3600)    return sprintf("Hour(%s)",    nice_print_period());    return sprintf("Hour(%s %s)",    base->nice_print(),    nice_print()); -  +  case 't': +  return "Calendar."+calendar_name()+".Hour";    default: -  return 0; +  return ::_sprintf(t,m);    }    })    return "error";    }       string nice_print()    {    if (ls==CALUNKNOWN) make_local();    return sprintf("%d:00 %s",ls/3600,tzname());    }       string format_nice()    {    if (ls==CALUNKNOWN) make_local();    if (!base) make_base();    return base->format_nice()+" "+sprintf("%d:00",ls/3600);    } -  +  + // ----------------------------------------------------------------- +  +  TimeRange place(TimeRange what,void|int force) +  { +  if (what->is_hour) +  return Hour("timeofday",rules,ux,what->len); +  if (what->is_minute) +  return minute()+(what->hour()->distance(what))->number_of_minutes(); +  if (what->is_fraction) +  { +  TimeRange t=what->hour()->distance(what); +  int s=t->len_s; +  int ns=t->len_ns; +  return +  Fraction("timeofday_f",rules,ux,0,what->len_s,what->len_s) +  ->_move(1,s,ns);    } -  +  if (what->is_second) +  return second()+(what->hour()->distance(what))->number_of_seconds();    -  +  ::place(what,force); +  } + } +    //------------------------------------------------------------------------   //! class Minute   //------------------------------------------------------------------------      function(mixed...:cMinute) Minute=cMinute; // inheritance purposes   class cMinute   {    constant is_minute=1;      //! inherits TimeofDay       inherit TimeofDay;    -  +  static void create_unixtime(int _ux,int _len) +  { +  ::create_unixtime(_ux,_len); +  if (ls==CALUNKNOWN) make_local(); +  ux-=ls%60; +  } +     void create_unixtime_default(int unixtime)    {    create_unixtime(unixtime,60);    }       static void create_now()    {    create_unixtime(time()/60*60,60);    }   
pike.git/lib/modules/Calendar.pmod/Time.pmod:1271:    len-=len%60;    }       TimeofDay _move(int n,int m)    {    if (m==0 || n==0) return this_object();    if (m%60) return Second("timeofday",rules,ux,len)->_move(n,m);    return Minute("timeofday",rules,ux+n*m,len)->autopromote();    }    -  string _sprintf(int t) +  string _sprintf(int t,mapping m)    {    switch (t)    {    case 'O':    if (!base) make_base();    if (len!=60)    return sprintf("Minute(%s)",    nice_print_period());    return sprintf("Minute(%s %s)",    base->nice_print(),    nice_print()); -  +  case 't': +  return "Calendar."+calendar_name()+".Minute";    default: -  return 0; +  return ::_sprintf(t,m);    }    }       string nice_print()    {    if (ls==CALUNKNOWN) make_local();    return sprintf("%d:%02d %s",ls/3600,(ls/60)%60,tzname());    }       string format_nice()    {    if (ls==CALUNKNOWN) make_local();    if (!base) make_base();    return base->format_nice()+" "+sprintf("%d:%02d",ls/3600,(ls/60)%60);    } -  +  +  TimeRange place(TimeRange what,void|int force) +  { +  if (what->is_hour) +  return hour()->place(what); +  if (what->is_minute) +  return Minute("timeofday",rules,ux,what->len); +  if (what->is_fraction) +  { +  TimeRange t=what->minute()->distance(what); +  int s=t->len_s; +  int ns=t->len_ns; +  return +  Fraction("timeofday_f",rules,ux,0,what->len_s,what->len_s) +  ->_move(1,s,ns);    } -  +  if (what->is_second) +  return second()+(what->minute()->distance(what))->number_of_seconds();    -  +  ::place(what,force); +  } + } +    //------------------------------------------------------------------------   //! class Second   //------------------------------------------------------------------------      function(mixed...:cSecond) Second=cSecond; // inheritance purposes   class cSecond   {    constant is_second=1;      //! inherits TimeofDay
pike.git/lib/modules/Calendar.pmod/Time.pmod:1345:    return Minute("timeofday",rules,ux,len)->autopromote();    return ::autopromote();    }       TimeofDay _move(int n,int m)    {    if (m==0 || n==0) return this_object();    return Second("timeofday",rules,ux+n*m,len)->autopromote();    }    -  string _sprintf(int t) +  string _sprintf(int t,mapping m)    {    switch (t)    {    case 'O':    if (len!=1)    return sprintf("Second(%s)",    nice_print_period());    if (!base) make_base();    return sprintf("Second(%s %s)",    base->nice_print(),    nice_print()); -  +  case 't': +  return "Calendar."+calendar_name()+".Second";    default: -  return 0; +  return ::_sprintf(t,m);    }    }       string nice_print()    {    if (ls==CALUNKNOWN) make_local();    return sprintf("%d:%02d:%02d %s",ls/3600,ls/60%60,ls%60,tzname()||"?");    }       string format_nice()
pike.git/lib/modules/Calendar.pmod/Time.pmod:1381:    if (!base) make_base();    return base->format_nice()+" "+    sprintf("%d:%02d:%02d",ls/3600,ls/60%60,ls%60);    }      // backwards compatible with calendar I    string iso_name()    { return this_object()->format_ymd()+" T"+format_tod(); }    string iso_short_name()    { return this_object()->format_ymd_short()+" T"+(format_tod()-":"); } +  +  +  TimeRange place(TimeRange what,void|int force) +  { +  if (what->is_hour) +  return hour()->place(what); +  if (what->is_minute) +  return minute()->place(what); +  if (what->is_fraction) +  { +  TimeRange t=what->second()->distance(what); +  int s=t->len_s; +  int ns=t->len_ns; +  return +  Fraction("timeofday_f",rules,ux,0,what->len_s,what->len_s) +  ->_move(1,s,ns);    } -  +  if (what->is_second) +  return second()+(what->second()->distance(what))->number_of_seconds();    -  +  ::place(what,force); +  } + } +    //------------------------------------------------------------------------   //! class Fraction   //! A Fraction is a part of a second, and/or a time period   //! with higher resolution then a second.   //!   //! It contains everything that is possible to do with a   //! <ref>Second</ref>, and also some methods of grabbing   //! the time period with higher resolution.   //!   //! note:
pike.git/lib/modules/Calendar.pmod/Time.pmod:1570:    {   // 1970-01-01 is julian day 2440588    jd-=2440588;    float fjd=((jd-(int)jd)+0.5)*86400;    ux=((int)jd)*86400+(int)(fjd);    ns=(int)(inano*(fjd-(int)fjd));       ls=CALUNKNOWN;    }    -  string _sprintf(int t) +  string _sprintf(int t,mapping m)    {    switch (t)    {    case 'O':    if (!base) make_base();    if (len_ns || len_s)    return sprintf("Fraction(%s)",    nice_print_period());    return sprintf("Fraction(%s %s)",    base->nice_print(),    nice_print()); -  +  case 't': +  return "Calendar."+calendar_name()+".Fraction";    default: -  return 0; +  return ::_sprintf(t,m);    }    }       int __hash() { return ux; }       string nice_print()    {    if (ls==CALUNKNOWN) make_local();    return sprintf("%d:%02d:%02d.%06d %s",    ls/3600,ls/60%60,ls%60,ns/1000,tzname());