Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| Amicron | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
| datestamp | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php declare(strict_types=1); |
| 2 | |
| 3 | namespace Satag\AmicronEntityBundle\Util; |
| 4 | |
| 5 | /** |
| 6 | * Amicron utility class |
| 7 | */ |
| 8 | class Amicron |
| 9 | { |
| 10 | /** |
| 11 | * Default Newline für alle Textfelder in Amicron |
| 12 | */ |
| 13 | public const NL = "\r\n"; |
| 14 | |
| 15 | public static function datestamp(\DateTime $date): int |
| 16 | { |
| 17 | $start = \DateTime::createFromFormat('d.m.Y H:i:s', '30.12.1899 00:00:00'); |
| 18 | |
| 19 | if (!$start) { |
| 20 | throw new \RuntimeException('Failed to create start date for datestamp calculation.'); |
| 21 | } |
| 22 | |
| 23 | $dateCopy = (clone $date)->setTime(0, 0, 0); |
| 24 | |
| 25 | return (int) $start->diff($dateCopy)->days; |
| 26 | } |
| 27 | } |