From a0d26c0973e711355b3b345a871aa6f835dd80a0 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Tue, 21 Feb 2012 20:20:23 +0000 Subject: [PATCH] strftime introduced to ResolveDateWildcards git-svn-id: https://svn.fhem.de/fhem/trunk@1278 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/docs/commandref.html | 20 +++++++++++++++----- fhem/fhem.pl | 18 ++++-------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/fhem/docs/commandref.html b/fhem/docs/commandref.html index 79b1def12..a18ff92ce 100644 --- a/fhem/docs/commandref.html +++ b/fhem/docs/commandref.html @@ -8175,8 +8175,9 @@ href="http://www.elv.de/output/controller.aspx?cid=74&detail=10&detail2=29870">U The regexp will be checked against the (complete!) device name or against the (complete!) devicename:event combination.
- <filename> may contain one or more of the following - wildcards (a subset of the Unix date command arguments): + <filename> may contain %-wildcards of the + POSIX strftime function of the underlying OS (see your strftime manual). + Common used wildcards are: - + FHEM also replaces %L by the value of the global logdir attribute.
+ Before using %V for ISO 8601 week numbers check if it is + correctly supported by your system (%V may not be replaced, replaced by an + empty string or by an incorrect ISO-8601 week number, especially + at the beginning of the year) + If you use %V you will also have to use %G + instead of %Y for the year!
Examples:
diff --git a/fhem/fhem.pl b/fhem/fhem.pl index a66f62a4a..d767c3cf6 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -2052,23 +2052,13 @@ CommandChain($$) sub ResolveDateWildcards($@) { + use POSIX qw(strftime); + my ($f, @t) = @_; return $f if(!$f); return $f if($f !~ m/%/); # Be fast if there is no wildcard - - my $S = sprintf("%02d", $t[0]); $f =~ s/%S/$S/g; - my $M = sprintf("%02d", $t[1]); $f =~ s/%M/$M/g; - my $H = sprintf("%02d", $t[2]); $f =~ s/%H/$H/g; - my $d = sprintf("%02d", $t[3]); $f =~ s/%d/$d/g; - my $m = sprintf("%02d", $t[4]+1); $f =~ s/%m/$m/g; - my $Y = sprintf("%04d", $t[5]+1900); $f =~ s/%Y/$Y/g; - my $w = sprintf("%d", $t[6]); $f =~ s/%w/$w/g; - my $j = sprintf("%03d", $t[7]+1); $f =~ s/%j/$j/g; - my $U = sprintf("%02d", int(($t[7]-$t[6]+6)/7)); $f =~ s/%U/$U/g; - my $V = sprintf("%02d", int(($t[7]-$t[6]+7)/7)+1); $f =~ s/%V/$V/g; - $f =~ s/%ld/$attr{global}{logdir}/g if($attr{global}{logdir}); #log directory - - return $f; + $f =~ s/%L/$attr{global}{logdir}/g if($attr{global}{logdir}); #log directory + return strftime($f,@t); } sub