Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
80.00% covered (warning)
80.00%
4 / 5
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
Amicron
80.00% covered (warning)
80.00%
4 / 5
0.00% covered (danger)
0.00%
0 / 1
2.03
0.00% covered (danger)
0.00%
0 / 1
 datestamp
80.00% covered (warning)
80.00%
4 / 5
0.00% covered (danger)
0.00%
0 / 1
2.03
1<?php declare(strict_types=1);
2
3namespace Satag\AmicronEntityBundle\Util;
4
5/**
6 * Amicron utility class
7 */
8class 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}