mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-21 07:56:03 +00:00
RESIDENTStk: use UConv::duration()
git-svn-id: https://svn.fhem.de/fhem/trunk@17590 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
575023a6ed
commit
03f80ccc78
@ -4,7 +4,6 @@ package main;
|
||||
use strict;
|
||||
use warnings;
|
||||
use Data::Dumper;
|
||||
use Time::Local;
|
||||
|
||||
use Unit;
|
||||
our (@RESIDENTStk_attr);
|
||||
@ -415,14 +414,14 @@ sub RESIDENTStk_Set($@) {
|
||||
readingsBulkUpdate(
|
||||
$hash,
|
||||
"lastDurSleep",
|
||||
RESIDENTStk_TimeDiff(
|
||||
UConv::duration(
|
||||
$datetime, ReadingsVal( $name, "lastSleep", "" )
|
||||
)
|
||||
);
|
||||
readingsBulkUpdate(
|
||||
$hash,
|
||||
"lastDurSleep_cr",
|
||||
RESIDENTStk_TimeDiff(
|
||||
UConv::duration(
|
||||
$datetime, ReadingsVal( $name, "lastSleep", "" ),
|
||||
"min"
|
||||
)
|
||||
@ -517,7 +516,7 @@ sub RESIDENTStk_Set($@) {
|
||||
readingsBulkUpdate(
|
||||
$hash,
|
||||
"lastDurAbsence",
|
||||
RESIDENTStk_TimeDiff(
|
||||
UConv::duration(
|
||||
$datetime,
|
||||
ReadingsVal( $name, "lastDeparture", "-" )
|
||||
)
|
||||
@ -525,7 +524,7 @@ sub RESIDENTStk_Set($@) {
|
||||
readingsBulkUpdate(
|
||||
$hash,
|
||||
"lastDurAbsence_cr",
|
||||
RESIDENTStk_TimeDiff(
|
||||
UConv::duration(
|
||||
$datetime,
|
||||
ReadingsVal( $name, "lastDeparture", "-" ),
|
||||
"min"
|
||||
@ -541,7 +540,7 @@ sub RESIDENTStk_Set($@) {
|
||||
readingsBulkUpdate(
|
||||
$hash,
|
||||
"lastDurPresence",
|
||||
RESIDENTStk_TimeDiff(
|
||||
UConv::duration(
|
||||
$datetime,
|
||||
ReadingsVal( $name, "lastArrival", "-" )
|
||||
)
|
||||
@ -549,7 +548,7 @@ sub RESIDENTStk_Set($@) {
|
||||
readingsBulkUpdate(
|
||||
$hash,
|
||||
"lastDurPresence_cr",
|
||||
RESIDENTStk_TimeDiff(
|
||||
UConv::duration(
|
||||
$datetime,
|
||||
ReadingsVal( $name, "lastArrival", "-" ), "min"
|
||||
)
|
||||
@ -3464,30 +3463,6 @@ sub RESIDENTStk_TimeSum($$) {
|
||||
|
||||
}
|
||||
|
||||
sub RESIDENTStk_TimeDiff ($$;$) {
|
||||
my ( $datetimeNow, $datetimeOld, $format ) = @_;
|
||||
|
||||
if ( $datetimeNow eq "" || $datetimeOld eq "" ) {
|
||||
$datetimeNow = "1970-01-01 00:00:00";
|
||||
$datetimeOld = "1970-01-01 00:00:00";
|
||||
}
|
||||
|
||||
my $timestampNow = time_str2num($datetimeNow);
|
||||
my $timestampOld = time_str2num($datetimeOld);
|
||||
my $timeDiff = $timestampNow - $timestampOld;
|
||||
|
||||
# return seconds
|
||||
return round( $timeDiff, 0 )
|
||||
if ( defined($format) && $format eq "sec" );
|
||||
|
||||
# return minutes
|
||||
return round( $timeDiff / 60, 0 )
|
||||
if ( defined($format) && $format eq "min" );
|
||||
|
||||
# return human readable format
|
||||
return UConv::s2hms( round( $timeDiff, 0 ) );
|
||||
}
|
||||
|
||||
sub RESIDENTStk_InternalTimer($$$$$) {
|
||||
my ( $modifier, $tim, $callback, $hash, $waitIfInitNotDone ) = @_;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user