Thank you for thinking with me!
I know the number of minutes, I just have to convert them to a date so I can test if current-time >= schedule-time.
I think I need something along the lines of:
next = Calendar.Day()->beginning() + Calendar.Minute()*x;
or for tomorrow:
next = Calendar.Day()->end() + Calendar.Minute()*x;
/Marc
If you want a point in time, as opposed to an interval of length, say, one minute, then your suggested code looks correct.
You can also do
Calendar.Month()->beginning()->minute()+4711;
(11) Result: Minute(Mon 4 Apr 2011 6:31 CEST)
The ->minute() will give you the minute (one minute long) that the beginning of the month is in.
Actually the ->beginning() seems superfluous:
Calendar.Month()->minute()+4711;
(12) Result: Minute(Mon 4 Apr 2011 6:31 CEST)
Calendar.Month()->beginning()->minute()+4711;
(11) Result: Minute(Mon 4 Apr 2011 6:31 CEST)
The ->minute() will give you the minute (one minute long) that the beginning of the month is in.
One possible gotcha here is that while
Calendar.Month()->beginning()->minute();
gives you the first minute of the month,
Calendar.Month()->end()->minute();
does not give you last minute of the month, but rather the first minute of next month. To get the last minute of the month, one has to do
Calendar.Month()->end()->minute()-1;
(this will have the same ->end() as the month does).
Of course, it gets even more fun with weeks, since
Calendar.Month()->end()->week();
will return a week which may or may not have any days at all in the current month. :-)
Hm, by the way, what happens if you do
t + Calendar.Day()*10;
on the day that daylight savings time starts? Since Calendar.Day() is the _current_ day, which in this case has only 23 hours, does that mean you add 230 hours to t? Or possibly 239?
You can also do
Calendar.Month()->minute(-1);
(1) Result: Minute(Sat 30 Apr 2011 23:59 CEST)
to actually get the last minute of the month.
Or, for the first one:
Calendar.Month()->minute(0);
(2) Result: Minute(Fri 1 Apr 2011 0:00 CEST)
This works for weeks too:
Calendar.Month()->week(-1);
(3) Result: Week(w17 2011)
pike-devel@lists.lysator.liu.se