2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-12 22:56:34 +00:00

strftime introduced to ResolveDateWildcards

git-svn-id: https://svn.fhem.de/fhem/trunk@1278 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2012-02-21 20:20:23 +00:00
parent eae2fd0fac
commit a0d26c0973
2 changed files with 19 additions and 19 deletions

View File

@ -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.
<br>
<code>&lt;filename&gt;</code> may contain one or more of the following
wildcards (a subset of the Unix date command arguments):
<code>&lt;filename&gt;</code> may contain %-wildcards of the
POSIX strftime function of the underlying OS (see your strftime manual).
Common used wildcards are:
<ul>
<li><code>%d</code> day of month (01..31)</li>
<li><code>%m</code> month (01..12)</li>
@ -8184,14 +8185,23 @@ href="http://www.elv.de/output/controller.aspx?cid=74&detail=10&detail2=29870">U
<li><code>%w</code> day of week (0..6); 0 represents Sunday
<li><code>%j</code> day of year (001..366)
<li><code>%U</code> week number of year with Sunday as first day of week (00..53)
<li><code>%V</code> week number of year with Monday as first day of week (01..53)
<li><code>%W</code> week number of year with Monday as first day of week (00..53)
</ul>
FHEM also replaces <code>%L</code> by the value of the global logdir attribute.<br>
Before using <code>%V</code> 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 <code>%V</code> you will also have to use %G
instead of %Y for the year!<br>
Examples:
<ul>
<code>define lamplog FileLog /var/tmp/lamp.log lamp</code><br>
<code>define lamplog FileLog %L/lamp.log lamp</code><br>
<code>define wzlog FileLog /var/tmp/wz-%Y-%U.log
wz:(measured-temp|actuator).*</code><br>
With ISO 8601 week numbers, if supported:<br>
<code>define wzlog FileLog /var/tmp/wz-%G-%V.log
wz:(measured-temp|actuator).*</code><br>
</ul>
<br>
</ul>

View File

@ -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