Skip to content

Commit

Permalink
Move the list of holidays to a separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
lexhouk committed Jun 27, 2022
1 parent a13f699 commit f5e8e2f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
10 changes: 10 additions & 0 deletions holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"month": 6,
"day": 28
},
{
"month": 8,
"day": 24
}
]
12 changes: 8 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
$days = json_decode(file_get_contents('days.json'), TRUE);
$day = $days[$day_of_week];
$name = $day['name'];
$holiday = FALSE;

if (
($month === '6' && $day_of_month === '28') ||
($month === '8' && $day_of_month === '24')
) {
foreach (json_decode(file_get_contents('holidays.json'), TRUE) as $date) {
if ($month == $date['month'] && $day_of_month == $date['day']) {
$holiday = TRUE;
}
}

if ($holiday) {
if (isset($day['delete'])) {
$name = mb_substr($name, $day['delete']);
}
Expand Down

0 comments on commit f5e8e2f

Please sign in to comment.