mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
57_Calendar.pm: add limit:when=today|tomorrow (as discussed with Boris)
git-svn-id: https://svn.fhem.de/fhem/trunk@18535 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
7677089d55
commit
4cfa52f3f9
@ -1995,6 +1995,18 @@ sub Calendar_Get($@) {
|
||||
for my $limit (@limits) {
|
||||
if($limit =~ /count=([1-9]+\d*)/) {
|
||||
$count= $1;
|
||||
} elsif($limit =~ /when=(today|tomorrow)/i) {
|
||||
my ($from,$to);
|
||||
if (lc($1) eq 'today') {
|
||||
$from = Calendar_GetSecondsFromMidnight();
|
||||
$to = DAYSECONDS - $from;
|
||||
$from *= -1;
|
||||
} else {
|
||||
$from = DAYSECONDS - Calendar_GetSecondsFromMidnight();
|
||||
$to = $from + DAYSECONDS;
|
||||
}
|
||||
push @filters, { ref => \&filter_endafter, param => $t+$from };
|
||||
push @filters, { ref => \&filter_startbefore, param => $t+$to };
|
||||
} elsif($limit =~ /from=([+-]?)(.+)/ ) {
|
||||
my $sign= $1 eq "-" ? -1 : 1;
|
||||
my ($error, $from)= Calendar_GetSecondsFromTimeSpec($2);
|
||||
@ -2226,6 +2238,12 @@ sub Calendar_DisarmTimer($) {
|
||||
}
|
||||
#
|
||||
|
||||
###################################
|
||||
sub Calendar_GetSecondsFromMidnight(){
|
||||
my @time = localtime();
|
||||
return (($time[2] * HOURSECONDS) + ($time[1] * MINUTESECONDS) + $time[0]);
|
||||
}
|
||||
|
||||
###################################
|
||||
sub Calendar_GetSecondsFromTimeSpec($) {
|
||||
|
||||
@ -3370,11 +3388,13 @@ sub CalendarEventsAsHtml($;$) {
|
||||
<tr><td><code>to=[+|-]<timespec></code></td><td>shows only events that start before
|
||||
a timespan <timespec> from now; use a minus sign for events in the
|
||||
past; <timespec> is described below in the Attributes section</td></tr>
|
||||
<tr><td><code>when=today|tomorrow</code></td><td>shows events for today or tomorrow</td></tr>
|
||||
</table><br>
|
||||
|
||||
Examples:<br>
|
||||
<code>get MyCalendar events limit:count=10</code><br>
|
||||
<code>get MyCalendar events limit:from=-2d</code><br>
|
||||
<code>get MyCalendar events limit:when=today</code><br>
|
||||
<code>get MyCalendar events limit:count=10,from=0,to=+10d</code><br>
|
||||
<br><br>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user