From adb9c59d7ce676814199ae3ee82709b577e38b01 Mon Sep 17 00:00:00 2001 From: "Mirar (Pontus Hagland)" <pike@sort.mirar.org> Date: Wed, 18 Oct 2000 13:01:19 +0200 Subject: [PATCH] nulltimerange fix added placement of time in weeks (using weekday and day placement) Rev: lib/modules/Calendar.pmod/Time.pmod:1.6 Rev: lib/modules/Calendar.pmod/TimeRanges.pmod:1.12 Rev: lib/modules/Calendar.pmod/YMD.pmod:1.15 --- lib/modules/Calendar.pmod/Time.pmod | 19 +++++++++++++++++++ lib/modules/Calendar.pmod/TimeRanges.pmod | 7 ++++--- lib/modules/Calendar.pmod/YMD.pmod | 7 +++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/lib/modules/Calendar.pmod/Time.pmod b/lib/modules/Calendar.pmod/Time.pmod index 63e7ac90fb..b92b2e6be1 100644 --- a/lib/modules/Calendar.pmod/Time.pmod +++ b/lib/modules/Calendar.pmod/Time.pmod @@ -1109,6 +1109,25 @@ class cSuperTimeRange } } +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 ({}); } + cMinute minute(void|int n) { error("no minutes in nulltimerange\n"); } + int number_of_minutes() { return 0; } + + array(cSecond) seconds(int ...range) { return ({}); } + cSecond second(void|int n) { error("no seconds in nulltimerange\n"); } + int number_of_seconds() { return 0; } + + string format_elapsed() { return "0:00:00"; } +} + //------------------------------------------------------------------------ //! class Hour //------------------------------------------------------------------------ diff --git a/lib/modules/Calendar.pmod/TimeRanges.pmod b/lib/modules/Calendar.pmod/TimeRanges.pmod index e2497b98b5..811d2e3e68 100644 --- a/lib/modules/Calendar.pmod/TimeRanges.pmod +++ b/lib/modules/Calendar.pmod/TimeRanges.pmod @@ -1,6 +1,6 @@ //! module Calendar -// $Id: TimeRanges.pmod,v 1.11 2000/10/18 10:05:46 mirar Exp $ +// $Id: TimeRanges.pmod,v 1.12 2000/10/18 11:01:18 mirar Exp $ #pike __REAL_VERSION__ @@ -1148,7 +1148,8 @@ class cSuperTimeRange //! is non-zero. <tt>`!</tt> on this timerange is true. -static class NullTimeRange +program NullTimeRange=cNullTimeRange; +static class cNullTimeRange { inherit TimeRange; @@ -1244,7 +1245,7 @@ static class NullTimeRange } } -NullTimeRange nulltimerange=NullTimeRange(); +cNullTimeRange nulltimerange=NullTimeRange(); // helper functions diff --git a/lib/modules/Calendar.pmod/YMD.pmod b/lib/modules/Calendar.pmod/YMD.pmod index 930f391925..846885d330 100644 --- a/lib/modules/Calendar.pmod/YMD.pmod +++ b/lib/modules/Calendar.pmod/YMD.pmod @@ -1765,12 +1765,19 @@ class cWeek TimeRange place(TimeRange what,void|int force) { + if (what->is_supertimerange) + return what->mend_overlap(map(what->parts,place,force)); +// return `|(@map(what->parts,place,force)); + if (what->is_year) return year()->place(what,force); // just fallback if (what->is_day) return place_day(what->week_day(),what->n,force); + if (what->is_timeofday) + return place(what->day(),force)->place(what,force); + error("place: Incompatible type %O\n",what); } -- GitLab