1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Timestamp.php
См. документацию.
1<?php
2declare(strict_types=1);
3
4namespace Bitrix\Im\V2\Message\Text\BbCode;
5
6use Bitrix\Im\V2\Message\Text\BbCode\Timestamp\DateFormat;
7use Bitrix\Im\V2\Message\Text\OpenBbCode;
8use Bitrix\Main\Application;
9use Bitrix\Main\Type\Date;
10use Bitrix\Main\Type\DateTime;
11
12final class Timestamp extends OpenBbCode
13{
14 private Date $date;
15 private DateFormat $formatCode;
16
17 private function __construct(Date $date, DateFormat $formatCode)
18 {
19 $this->date = $date;
20 $this->formatCode = $formatCode;
21 }
22
23 public static function build(Date $date, DateFormat $formatCode): self
24 {
25 return new self($date, $formatCode);
26 }
27
28 public function toPlain(): string
29 {
30 $format = $this->getFormat();
31
32 return FormatDate($format, $this->date);
33 }
34
35 public static function getName(): string
36 {
37 return 'TIMESTAMP';
38 }
39
40 protected function getValue(): ?string
41 {
42 return (string)$this->date->getTimestamp();
43 }
44
45 protected function getAdditionalParams(): array
46 {
47 return ['FORMAT' => $this->formatCode->value];
48 }
49
50 private function getFormat(): string
51 {
52 $culture = Application::getInstance()->getContext()->getCulture();
53 if ($culture === null)
54 {
55 return '';
56 }
57
58 $format = $culture->get($this->formatCode->value);
59
60 if ($this->formatCode === DateFormat::FormatDatetime || $this->formatCode === DateFormat::FormatDate)
61 {
62 return DateTime::convertFormatToPhp($format);
63 }
64
65 return $format;
66 }
67}
static build(Date $date, DateFormat $formatCode)
Определения Timestamp.php:23
static getInstance()
Определения servicelocator.php:33
Определения date.php:9
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$culture
Определения include.php:61
FormatDate($format="", $timestamp=false, $now=false, ?string $languageId=null)
Определения tools.php:871