Skip to content

Commit

Permalink
always request year_type CIVIL
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRDOrazio committed Dec 8, 2024
1 parent ddb3e92 commit e60820a
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 7 deletions.
49 changes: 49 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"version": "2.0.0",
"options": {
"env": {
"APP_PROTOCOL": "http",
"APP_HOST": "localhost",
"APP_PORT": "3002"
}
},
"tasks": [
{
"label": "launch-browser",
"type": "shell",
"windows": {
"command": "${command:workbench.action.terminal.sendSequence}",
"args": [
{
"text": "start ${APP_PROTOCOL}://${APP_HOST}:${APP_PORT}\n" // For Windows
}
],
"problemMatcher": []
},
"linux": {
"command": "/bin/bash",
"args": [
"-c",
"if grep -q microsoft /proc/version; then powershell.exe Start-Process ${APP_PROTOCOL}://${APP_HOST}:${APP_PORT}; else xdg-open ${APP_PROTOCOL}://${APP_HOST}:${APP_PORT}; fi"
],
"problemMatcher": []
},
"osx": {
"command": "open ${APP_PROTOCOL}://${APP_HOST}:${APP_PORT}", // For macOS
"problemMatcher": []
}
},
{
"label": "php-server",
"type": "shell",
"command": "php -S ${APP_HOST}:${APP_PORT}",
"group": {
"kind": "build",
"isDefault": true
},
"dependsOn": [
"launch-browser"
]
}
]
}
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
error_reporting(-1);
ini_set('display_errors', '1');

include './vendor/autoload.php';

Expand Down
11 changes: 6 additions & 5 deletions src/LiturgyOfTheDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class LiturgyOfTheDay
private array $LitCalData = [];
private array $LitCalFeed = [];
private \IntlDateFormatter $monthDayFmt;
private array $queryParams = [];
private const PHONETIC_PRONUNCATION_MAPPING = [
'/Blessed /' => '<phoneme alphabet="ipa" ph="ˈblɛsɪd">Blessed</phoneme> ',
'/Antiochia/' => '<phoneme alphabet="ipa" ph="ɑntɪˈokiɑ">Antiochia</phoneme>',
Expand Down Expand Up @@ -359,8 +358,7 @@ private function sendMetadataReq(): void
*/
/**
* Sends a request to the calendar API at $this->CalendarURL
* with the query parameters $this->queryParams, with the
* Accept-Language header set to $this->Locale and the
* with the Accept-Language header set to $this->Locale and the
* Accept header set to application/json.
*
* If the request fails, it will die with an error message.
Expand All @@ -374,7 +372,7 @@ private function sendReq()
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $this->CalendarURL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($this->queryParams));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(["year_type" => "CIVIL"]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Accept-Language: $this->Locale",
"Accept: application/json"
Expand Down Expand Up @@ -413,7 +411,8 @@ private function filterEventsToday()
{
$dateTimeToday = ( new \DateTime('now') )->format("Y-m-d") . " 00:00:00";
$dateToday = \DateTime::createFromFormat('Y-m-d H:i:s', $dateTimeToday, new \DateTimeZone('UTC'));
$dateTodayTimestamp = intval($dateToday->format("U"));
$dateTodayTimestampStr = $dateToday->format("U");
$dateTodayTimestamp = intval($dateTodayTimestampStr);
$dateToday->add(new \DateInterval('PT15M'));
$idx = 0;
foreach ($this->LitCalData as $value) {
Expand Down Expand Up @@ -660,6 +659,8 @@ private function sendResponse()
echo json_encode($this->LitCalFeed[0]);
} elseif (count($this->LitCalFeed) > 1) {
echo json_encode($this->LitCalFeed);
} else {
die("Missing data from response: LitCalFeed seems to by empty or null? " . count($this->LitCalFeed));
}
}

Expand Down

0 comments on commit e60820a

Please sign in to comment.