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

version» Context lines:

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: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:1232:    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
pike.git/lib/modules/Calendar.pmod/Time.pmod:1314:    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:1395:    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: