1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
datetime.php
См. документацию.
1<?
2
3namespace Bitrix\Main\UI\Filter;
4
5
6use Bitrix\Main\Type as MainType;
7
8
10{
12 protected $date;
13
15 protected $dateTime;
16
18 protected $timestamp;
19
20
25 public function __construct($timestamp = "")
26 {
27 $this->timestamp = $timestamp;
28
29 if (empty($this->timestamp))
30 {
31 $this->date = new MainType\Date();
32 $this->timestamp = $this->date->getTimestamp();
33 }
34
35 $this->dateTime = MainType\DateTime::createFromTimestamp($this->timestamp);
36 static::adjustTime($this->dateTime);
37 }
38
39
45 public static function adjustTime(MainType\DateTime $dateTime)
46 {
47 if(\CTimeZone::Enabled())
48 {
49 static $diff = null;
50 if($diff === null)
51 {
52 $diff = \CTimeZone::GetOffset();
53 }
54 if($diff <> 0)
55 {
56 $dateTime->add(($diff > 0? "-":"")."PT".abs($diff)."S");
57 }
58 }
59 }
60
61
62
67 public function month()
68 {
69 $date = new MainType\Date($this->toString());
70 return $date->format("n");
71 }
72
73
78 public function year()
79 {
80 $date = new MainType\Date($this->toString());
81 return $date->format("Y");
82 }
83
84
89 public function quarter()
90 {
91 $date = new MainType\Date($this->toString());
92 return Quarter::get($date);
93 }
94
95
100 public function quarterStart()
101 {
102 $startDate = Quarter::getStartDate($this->quarter(), $this->year());
104 static::adjustTime($dateTime);
105 return $dateTime->toString();
106 }
107
108
113 public function quarterEnd()
114 {
115 $endDate = Quarter::getEndDate($this->quarter(), $this->year());
117 $dateTime->add("- 1 second");
118 return $dateTime->toString();
119 }
120
121
127 public function offset($offset)
128 {
130 $date->add($offset);
131 static::adjustTime($date);
132 return $date->toString();
133 }
134
135
140 public function toString()
141 {
142 return $this->dateTime->toString();
143 }
144
145
150 public function getTimestamp()
151 {
152 return $this->timestamp;
153 }
154}
$startDate
Определения basket_discount_convert.php:125
Определения date.php:9
getTimestamp()
Определения date.php:218
static createFromTimestamp($timestamp)
Определения datetime.php:246
toString(Context\Culture $culture=null)
Определения datetime.php:86
static createFromUserTime($timeString)
Определения datetime.php:180
static adjustTime(MainType\DateTime $dateTime)
Определения datetime.php:45
__construct($timestamp="")
Определения datetime.php:25
offset($offset)
Определения datetime.php:127
static get(Date $date)
Определения quarter.php:44
static getStartDate($quarter, $year)
Определения quarter.php:74
static getEndDate($quarter, $year)
Определения quarter.php:90
MakeTimeStamp($datetime, $format=false)
Определения tools.php:538