1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
quarter.php
См. документацию.
1<?
2
3namespace Bitrix\Main\UI\Filter;
4
5use Bitrix\Main\Type\Date;
6
7
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}
$startDate
Определения basket_discount_convert.php:125
Определения date.php:9
static getCurrent()
Определения quarter.php:32
const Q1
Определения quarter.php:14
const Q3_START
Определения quarter.php:22
const Q4_END
Определения quarter.php:25
const Q2_END
Определения quarter.php:21
const Q3
Определения quarter.php:16
static get(Date $date)
Определения quarter.php:44
const Q4_START
Определения quarter.php:24
const Q4
Определения quarter.php:17
const Q2
Определения quarter.php:15
static getStartDate($quarter, $year)
Определения quarter.php:74
const Q1_START
Определения quarter.php:18
const Q3_END
Определения quarter.php:23
const Q2_START
Определения quarter.php:20
static getEndDate($quarter, $year)
Определения quarter.php:90
const Q1_END
Определения quarter.php:19
MakeTimeStamp($datetime, $format=false)
Определения tools.php:538
$year
Определения payment.php:9