Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tasks-php
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
Адлан Шамавов
tasks-php
Commits
d785a12f
Commit
d785a12f
authored
11 months ago
by
Nikita Chernykh
Browse files
Options
Downloads
Plain Diff
Merge branch 'PTPS_Function_5' into 'main'
Ptps function 5 See merge request
!5
parents
33d65541
6cfdbf5a
No related branches found
No related tags found
1 merge request
!5
Ptps function 5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
index.php
+12
-1
12 additions, 1 deletion
index.php
src/Functions.php
+14
-0
14 additions, 0 deletions
src/Functions.php
with
26 additions
and
1 deletion
index.php
+
12
−
1
View file @
d785a12f
...
...
@@ -70,6 +70,17 @@
[
'name'
=>
'Посуда'
,
'depth'
=>
1
,],
];
print_r
(
$func
->
prepareMenu
(
$aMenu
));
?>
?>
<h1>
Function 5
</h1>
<?php
print
"<h2>До НГ: </h2>"
;
try
{
print
$func
->
howDaysToNy
(
new
DateTimeImmutable
());
}
catch
(
Exception
$e
)
{
print
$e
->
getMessage
();
}
?>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/Functions.php
+
14
−
0
View file @
d785a12f
...
...
@@ -137,5 +137,19 @@ class Functions
* ['name' => 'Посуда','depth' => 1,],]],
* ];
*/
/**
* Функция рассчитывает кол-во дней до нового года
* @param DateTimeImmutable $date дата от которой, необходимо рассчитать кол-во дней
* @return int
* @throws Exception
*/
public
function
howDaysToNy
(
DateTimeImmutable
$date
):
int
{
$endYear
=
date
(
"Y-12-31"
,
date_timestamp_get
(
$date
));
$dateInterval
=
date_diff
(
new
DateTimeImmutable
(
$endYear
),
$date
);
return
(
int
)
$dateInterval
->
format
(
"%a"
)
+
1
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment