Hi,
Pike 7.8.352 (Debian)
In hilfe:
Calendar.now();
(21) Result: Fraction(Thu 7 Apr 2011 12:26:15.216691 CEST)
Calendar.Hour()+Calendar.Minute();
(22) Result: Minute(Thu 7 Apr 2011 12:01 CEST - 13:01 CEST)
Calendar.Month()+Calendar.Minute();
(23) Result: Minute(Fri 1 Apr 2011 0:01 CEST - Sun 1 May 2011 0:01 CEST)
So Hour is calculated from the beginning of the last hour + 1 minute, and Month calculates starting of the month until next month + 1 minute.
I expected the behaviour to be the same as with Calendar.Hour()?
Best regards,
Marc Dirix
Huh? The current hour is 12:00..13:00 (since the time has passed 12:00 but not 13:00). Add one minute to each side and you get the interval 12:01-13:01 instead. The current month is 2011-04-01T00:00.. 2011-05-01T00:00 (since the time has passed 2011-04-01T00:00 but not 2011-05-01T00:00). Add one minute to each side and you get the interval 2011-04-01T00:01..2011-05-01T00:01 instead. So the behaviour is the same.
Hour starts from the beginning of the hour and ends at the end of the hour, and month start at the beginning of the month and ends at the end of the month:
| > Calendar.Hour()->beginning(); Calendar.Hour()->end(); | (1) Result: Hour(Thu 7 Apr 2011 16:00 CEST sharp) | (2) Result: Hour(Thu 7 Apr 2011 17:00 CEST sharp) | > Calendar.Month()->beginning(); Calendar.Month()->end(); | (3) Result: Month(Fri 1 Apr 2011 0:00 CEST sharp) | (4) Result: Month(Sun 1 May 2011 0:00 CEST sharp)
The beginning and end time has a length of 0 and is marked with the 'sharp' flag in the printout above. 0-length timespans might not do what you expect:
| > Calendar.Hour()->beginning()+4711; | (6) Result: Hour(Thu 7 Apr 2011 16:00 CEST sharp) | > Calendar.Hour()->beginning()+47110; | (7) Result: Hour(Thu 7 Apr 2011 16:00 CEST sharp)
Still continuing, maybe I've asked something similar before:
Calendar.Week()->beginning() + Calendar.Day()*2 + Calendar.Minute()*480;
Result: Hour(Wed 13 Apr 2011 0:00 CEST sharp)
Why doesn't it count the 480 minutes here? Whereas in this example:
object a = Calendar.Week()->beginning() + Calendar.Day()*2; a;
Result: Day(Wed 13 Apr 2011 0:00 CEST sharp)
a + Calendar.Minute()*480;
Result: Hour(Wed 13 Apr 2011 8:00 CEST sharp)
however, working as expected, and easiest:
Calendar.Week()->day(3)->minute(480);
Result: Minute(Wed 13 Apr 2011 8:00 CEST)
/Marc
That's an old bug that I thought would be fixed by now. Pike optimizes the + call and calls `+ with more than one argument. The Calendar module ignores all other arguments than the first.
(I think it's that one anyway.)
On Tue, Apr 12, 2011 at 10:55:01AM +0200, Marc Dirix wrote:
Calendar.Week()->beginning() + Calendar.Day()*2 + Calendar.Minute()*480;
Result: Hour(Wed 13 Apr 2011 0:00 CEST sharp) Why doesn't it count the 480 minutes here?
it appears do be doing: Calendar.Week()->beginning() + (Calendar.Day()*2 + Calendar.Minute()*480);
Calendar.Day()*2 + Calendar.Minute()*480;
(1) Result: Hour(Tue 12 Apr 2011 8:00 CST - Thu 14 Apr 2011 8:00 CST)
so the unexpected part here too is that this moves the timeframe, but does not add to the length. we already saw this in other examples...
greetings, martin.
Hm, yes. There's something odd with the second argument of `+, however; adding them one at a time works:
object o=Calendar.Week()->beginning();
o+Calendar.Day()*2+Calendar.Minute()*480;
(1) Result: Hour(Wed 13 Apr 2011 0:00 CEST sharp)
o=o+Calendar.Day()*2;
(2) Result: Day(Wed 13 Apr 2011 0:00 CEST sharp)
o=o+Calendar.Minute()*480;
(3) Result: Hour(Wed 13 Apr 2011 8:00 CEST sharp)
pike-devel@lists.lysator.liu.se