Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
quarter.php
1
<?
2
3
namespace
Bitrix\Main\UI\Filter
;
4
5
use
Bitrix\Main\Type\Date
;
6
7
12
class
Quarter
13
{
14
const
Q1
= 1;
15
const
Q2
= 2;
16
const
Q3
= 3;
17
const
Q4
= 4;
18
const
Q1_START
= 1;
19
const
Q1_END
= 3;
20
const
Q2_START
= 4;
21
const
Q2_END
= 6;
22
const
Q3_START
= 7;
23
const
Q3_END
= 9;
24
const
Q4_START
= 10;
25
const
Q4_END
= 12;
26
27
32
public
static
function
getCurrent
()
33
{
34
$date =
new
Date
();
35
return
self::get
($date);
36
}
37
38
44
public
static
function
get
(
Date
$date)
45
{
46
$currentMonth = $date->format(
"n"
);
47
$currentQuarter =
self::Q1
;
48
49
if
($currentMonth >= self::Q2_START && $currentMonth <= self::Q2_END)
50
{
51
$currentQuarter =
self::Q2
;
52
}
53
54
if
($currentMonth >= self::Q3_START && $currentMonth <= self::Q3_END)
55
{
56
$currentQuarter =
self::Q3
;
57
}
58
59
if
($currentMonth >= self::Q4_START && $currentMonth <= self::Q4_END)
60
{
61
$currentQuarter =
self::Q4
;
62
}
63
64
return
$currentQuarter;
65
}
66
67
74
public
static
function
getStartDate
($quarter, $year)
75
{
76
$startMonth = constant(
"self::Q"
.$quarter.
"_START"
);
77
$startDate = Date::createFromTimestamp(mktime(0, 0, 0, $startMonth, 1, $year));
78
$startDateString = $startDate->toString();
79
80
return
$startDateString;
81
}
82
83
90
public
static
function
getEndDate
($quarter, $year)
91
{
92
$date = Date::createFromTimestamp(\MakeTimeStamp(self::getStartDate($quarter, $year)));
93
$date->add(
"3 months"
);
94
return
$date->toString();
95
}
96
}
Bitrix\Main\Type\Date
Definition
date.php:9
Bitrix\Main\UI\Filter\Quarter
Definition
quarter.php:13
Bitrix\Main\UI\Filter\Quarter\getCurrent
static getCurrent()
Definition
quarter.php:32
Bitrix\Main\UI\Filter\Quarter\Q1
const Q1
Definition
quarter.php:14
Bitrix\Main\UI\Filter\Quarter\Q3_START
const Q3_START
Definition
quarter.php:22
Bitrix\Main\UI\Filter\Quarter\Q4_END
const Q4_END
Definition
quarter.php:25
Bitrix\Main\UI\Filter\Quarter\Q2_END
const Q2_END
Definition
quarter.php:21
Bitrix\Main\UI\Filter\Quarter\Q3
const Q3
Definition
quarter.php:16
Bitrix\Main\UI\Filter\Quarter\get
static get(Date $date)
Definition
quarter.php:44
Bitrix\Main\UI\Filter\Quarter\Q4_START
const Q4_START
Definition
quarter.php:24
Bitrix\Main\UI\Filter\Quarter\Q4
const Q4
Definition
quarter.php:17
Bitrix\Main\UI\Filter\Quarter\Q2
const Q2
Definition
quarter.php:15
Bitrix\Main\UI\Filter\Quarter\getStartDate
static getStartDate($quarter, $year)
Definition
quarter.php:74
Bitrix\Main\UI\Filter\Quarter\Q1_START
const Q1_START
Definition
quarter.php:18
Bitrix\Main\UI\Filter\Quarter\Q3_END
const Q3_END
Definition
quarter.php:23
Bitrix\Main\UI\Filter\Quarter\Q2_START
const Q2_START
Definition
quarter.php:20
Bitrix\Main\UI\Filter\Quarter\getEndDate
static getEndDate($quarter, $year)
Definition
quarter.php:90
Bitrix\Main\UI\Filter\Quarter\Q1_END
const Q1_END
Definition
quarter.php:19
Bitrix\Main\UI\Filter
Definition
actions.php:3
modules
main
lib
ui
filter
quarter.php
Создано системой
1.10.0