mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-12-06 02:13:55 +00:00
38 lines
983 B
PHP
38 lines
983 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Chill\ZimbraBundle\Calendar\Connector\ZimbraConnector;
|
|
|
|
use Zimbra\Mail\Struct\DtTimeInfo;
|
|
|
|
/**
|
|
* Class DateConverter.
|
|
*
|
|
* Provides methods for converting PHP DateTime objects
|
|
* into specific date-time formats or representations.
|
|
*/
|
|
final readonly class DateConverter
|
|
{
|
|
public const FORMAT_DATE_TIME = 'Ymd\THis';
|
|
|
|
/**
|
|
* Converts a PHP DateTimeInterface object into a Zimbra-specific DtTimeInfo object.
|
|
*
|
|
* @param \DateTimeInterface $date the date to be converted
|
|
*
|
|
* @return DtTimeInfo the converted DtTimeInfo object
|
|
*/
|
|
public function phpToZimbraDateTime(\DateTimeInterface $date): DtTimeInfo
|
|
{
|
|
return new DtTimeInfo($date->format(self::FORMAT_DATE_TIME), $date->getTimezone()->getName());
|
|
}
|
|
}
|