Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
66.67% covered (warning)
66.67%
4 / 6
CRAP
57.14% covered (warning)
57.14%
4 / 7
SiestaDateTime
0.00% covered (danger)
0.00%
0 / 1
66.67% covered (warning)
66.67%
4 / 6
8.83
57.14% covered (warning)
57.14%
4 / 7
 getJSONDateTime
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getSQLDateTime
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getSQLDate
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getSQLTime
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 stringToTime
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 equals
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
<?php
declare(strict_types = 1);
namespace Siesta\Util;
/**
 * @author Gregor Müller
 */
class SiestaDateTime extends \DateTime
{
    /**
     * @return string
     */
    function getJSONDateTime() : string
    {
        return $this->format("Y-m-d\\TH:i:s");
    }
    /**
     * @return string
     */
    public function getSQLDateTime() : string
    {
        return $this->format("Y-m-d H:i:s");
    }
    /**
     * @return string
     */
    public function getSQLDate() : string
    {
        return $this->format("Y-m-d");
    }
    /**
     * @return string
     */
    public function getSQLTime() : string
    {
        return $this->format("H:i:s");
    }
    /**
     * @param string $dateString
     *
     * @return void
     */
    public function stringToTime(string $dateString)
    {
        $this->setTimestamp(strtotime($dateString));
    }
    /**
     * @param SiestaDateTime $dateTime
     *
     * @return bool
     */
    public function equals(SiestaDateTime $dateTime)
    {
        return ($this->getTimestamp() === $dateTime->getTimestamp());
    }
}