1 |
efrain |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace OpenSpout\Common\Entity\Cell;
|
|
|
6 |
|
|
|
7 |
use DateInterval;
|
|
|
8 |
use OpenSpout\Common\Entity\Cell;
|
|
|
9 |
use OpenSpout\Common\Entity\Style\Style;
|
|
|
10 |
|
|
|
11 |
final class DateIntervalCell extends Cell
|
|
|
12 |
{
|
|
|
13 |
private readonly DateInterval $value;
|
|
|
14 |
|
|
|
15 |
/**
|
|
|
16 |
* For Excel make sure to set a format onto the style (Style::setFormat()) with the left most unit enclosed with
|
|
|
17 |
* brackets: '[h]:mm', '[hh]:mm:ss', '[m]:ss', '[s]', etc.
|
|
|
18 |
* This makes sure excel knows what to do with the remaining time that exceeds this unit. Without brackets Excel
|
|
|
19 |
* will interpret the value as date time and not duration if it is greater or equal 1.
|
|
|
20 |
*/
|
|
|
21 |
public function __construct(DateInterval $value, ?Style $style)
|
|
|
22 |
{
|
|
|
23 |
$this->value = $value;
|
|
|
24 |
parent::__construct($style);
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
public function getValue(): DateInterval
|
|
|
28 |
{
|
|
|
29 |
return $this->value;
|
|
|
30 |
}
|
|
|
31 |
}
|