Branch: Tag:

2001-07-18

2001-07-18 10:03:39 by Martin Nilsson <mani@lysator.liu.se>

Backported bugfixes from 7.3

Rev: lib/modules/Calendar.pmod/Event.pmod:1.12
Rev: lib/modules/Calendar.pmod/Events.pmod:1.9
Rev: lib/modules/Calendar.pmod/ISO.pmod:1.5
Rev: lib/modules/Calendar.pmod/Islamic.pmod:1.5
Rev: lib/modules/Calendar.pmod/Language.pmod:1.16
Rev: lib/modules/Calendar.pmod/Time.pmod:1.12
Rev: lib/modules/Calendar.pmod/TimeRanges.pmod:1.14
Rev: lib/modules/Calendar.pmod/Timezone.pmod:1.17
Rev: lib/modules/Calendar.pmod/YMD.pmod:1.30

155:   // 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
194:    {   #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());
292:       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)
698:   //! 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();
726:   //! 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"
783:    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();
939:    :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
1135:    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   {
1179:    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);
1200:    }       -  string _sprintf(int t) +  string _sprintf(int t,mapping m)    {    if (catch {    switch (t)
1213:    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";
1232:    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   //------------------------------------------------------------------------
1247:       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);
1278:    return Minute("timeofday",rules,ux+n*m,len)->autopromote();    }    -  string _sprintf(int t) +  string _sprintf(int t,mapping m)    {    switch (t)    {
1290:    return sprintf("Minute(%s %s)",    base->nice_print(),    nice_print()); +  case 't': +  return "Calendar."+calendar_name()+".Minute";    default: -  return 0; +  return ::_sprintf(t,m);    }    }   
1307:    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   //------------------------------------------------------------------------
1352:    return Second("timeofday",rules,ux+n*m,len)->autopromote();    }    -  string _sprintf(int t) +  string _sprintf(int t,mapping m)    {    switch (t)    {
1364:    return sprintf("Second(%s %s)",    base->nice_print(),    nice_print()); +  case 't': +  return "Calendar."+calendar_name()+".Second";    default: -  return 0; +  return ::_sprintf(t,m);    }    }   
1388:    { 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
1577:    ls=CALUNKNOWN;    }    -  string _sprintf(int t) +  string _sprintf(int t,mapping m)    {    switch (t)    {
1589:    return sprintf("Fraction(%s %s)",    base->nice_print(),    nice_print()); +  case 't': +  return "Calendar."+calendar_name()+".Fraction";    default: -  return 0; +  return ::_sprintf(t,m);    }    }