Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
datetime.php
1
<?
2
3
namespace
Bitrix\Main\UI\Filter
;
4
5
6
use
Bitrix\Main\Type
as
MainType
;
7
8
9
class
DateTime
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
());
103
$dateTime
= MainType\DateTime::createFromTimestamp(MakeTimeStamp($startDate));
104
static::adjustTime(
$dateTime
);
105
return
$dateTime
->toString();
106
}
107
108
113
public
function
quarterEnd
()
114
{
115
$endDate = Quarter::getEndDate($this->
quarter
(), $this->
year
());
116
$dateTime
= MainType\DateTime::createFromUserTime($endDate);
117
$dateTime
->add(
"- 1 second"
);
118
return
$dateTime
->toString();
119
}
120
121
127
public
function
offset
($offset)
128
{
129
$date
= MainType\DateTime::createFromTimestamp($this->
getTimestamp
());
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
}
Bitrix\Main\Type\Date
Definition
date.php:9
Bitrix\Main\Type\Date\getTimestamp
getTimestamp()
Definition
date.php:215
Bitrix\Main\Type\DateTime
Definition
datetime.php:9
Bitrix\Main\Type\DateTime\toString
toString(Context\Culture $culture=null)
Definition
datetime.php:86
Bitrix\Main\UI\Filter\DateTime\$timestamp
$timestamp
Definition
datetime.php:18
Bitrix\Main\UI\Filter\DateTime\month
month()
Definition
datetime.php:67
Bitrix\Main\UI\Filter\DateTime\quarterStart
quarterStart()
Definition
datetime.php:100
Bitrix\Main\UI\Filter\DateTime\$date
$date
Definition
datetime.php:12
Bitrix\Main\UI\Filter\DateTime\toString
toString()
Definition
datetime.php:140
Bitrix\Main\UI\Filter\DateTime\quarterEnd
quarterEnd()
Definition
datetime.php:113
Bitrix\Main\UI\Filter\DateTime\getTimestamp
getTimestamp()
Definition
datetime.php:150
Bitrix\Main\UI\Filter\DateTime\adjustTime
static adjustTime(MainType\DateTime $dateTime)
Definition
datetime.php:45
Bitrix\Main\UI\Filter\DateTime\__construct
__construct($timestamp="")
Definition
datetime.php:25
Bitrix\Main\UI\Filter\DateTime\year
year()
Definition
datetime.php:78
Bitrix\Main\UI\Filter\DateTime\$dateTime
$dateTime
Definition
datetime.php:15
Bitrix\Main\UI\Filter\DateTime\offset
offset($offset)
Definition
datetime.php:127
Bitrix\Main\UI\Filter\DateTime\quarter
quarter()
Definition
datetime.php:89
Bitrix\Main\Type
Definition
collection.php:2
Bitrix\Main\UI\Filter
Definition
actions.php:3
modules
main
lib
ui
filter
datetime.php
Создано системой
1.10.0