Skip to content
This repository has been archived by the owner on Mar 30, 2024. It is now read-only.

Commit

Permalink
Fix #36
Browse files Browse the repository at this point in the history
  • Loading branch information
kimbtech committed Apr 5, 2021
1 parent 066f86e commit d0c3f7b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
4 changes: 3 additions & 1 deletion core/InputParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public static function getEndTimestamp(string $t) : int {
}
}

$timestamp = strtotime($plusOneDay ? "tomorrow" : "today") + 3600 * $hs + 60 * $mins;
$timestamp = strtotime($plusOneDay ? "tomorrow" : "today")
+ 3600 * ($hs + Time::getTimeChangeDifference())
+ 60 * $mins;
}
else if( isset($matches[2]) ){ // Gruppe 2, d.h. Minuten- und/oder Stundenangabe
$hs = 0;
Expand Down
24 changes: 24 additions & 0 deletions core/Time.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,29 @@ public static function secToTime(int $t) : string {
}
return self::$time->getDurationString($t);
}

public static function isSummertime(int $now = null) : bool {
return date('I', is_null($now) ? time() : $now) === '1';
}

public static function getTimeChangeDifference(int $now = null) : int {
$now = is_null($now) ? time() : $now;
$todayNight = self::isSummertime(strtotime("today 00:00", $now));
$todayMid = self::isSummertime(strtotime("today 12:00", $now));
if( $todayMid === $todayNight || intval(date('G', $now)) < 3 ){
return 0;
}
else {
if( !$todayNight && $todayMid ){
return -1;
}
if( $todayNight && !$todayMid ){
return +1;
}
else{
return 0;
}
}
}
}
?>
2 changes: 1 addition & 1 deletion core/Utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
class Utilities {

const VERSION = 'v1.0.15';
const VERSION = 'v1.0.16';

const DEFAULT_LINE_LENGTH = 125;

Expand Down

0 comments on commit d0c3f7b

Please sign in to comment.