Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iqdevTranningProgram
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Адлан Шамавов
iqdevTranningProgram
Merge requests
!6
Ptps controller 6
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Ptps controller 6
PTPS_Controller_6
into
main
Overview
4
Commits
14
Pipelines
0
Changes
3
Merged
Адлан Шамавов
requested to merge
PTPS_Controller_6
into
main
11 months ago
Overview
4
Commits
14
Pipelines
0
Changes
3
Expand
0
0
Merge request reports
Viewing commit
ca5ff1b7
Show latest version
3 files
+
20
−
6
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
ca5ff1b7
Merge branch 'PTPS_Controller_1' into PTPS_Controller_2
· ca5ff1b7
Адлан Шамавов
authored
11 months ago
src/Action/Functions.php
+
20
−
0
Options
@@ -6,6 +6,9 @@ namespace App\Action;
use
Exception
;
use
DateTimeImmutable
;
use
DateTime
;
use
DatePeriod
;
use
DateInterval
;
class
Functions
{
@@ -100,4 +103,21 @@ class Functions
$dateInterval
=
date_diff
(
new
DateTimeImmutable
(
$endYear
),
$date
);
return
(
int
)
$dateInterval
->
format
(
"%a"
)
+
1
;
}
/**
* Вернет все пятницы 13 в году
* @param int $year год, в котором необходимо произвести расчет
* @return DateTimeImmutable[]
* @throws Exception
*/
public
function
countFriday13
(
int
$year
):
iterable
{
$startDate
=
new
DateTime
(
"
$year
-01-01 Friday"
);
++
$year
;
$endDate
=
new
DateTime
(
"
$year
-01-01"
);
$interval
=
new
DateInterval
(
'P7D'
);
foreach
(
new
DatePeriod
(
$startDate
,
$interval
,
$endDate
)
as
$day
)
{
yield
new
DateTimeImmutable
(
$day
->
format
(
"Y-m-d"
));
}
}
}
\ No newline at end of file
Loading