Skip to content

Commit

Permalink
Merge pull request #289 from Liturgical-Calendar/development
Browse files Browse the repository at this point in the history
fix iCalendar output
  • Loading branch information
JohnRDOrazio authored Jan 25, 2025
2 parents 6a3d1c9 + 4759e29 commit 42e233f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 41 deletions.
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/new_bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ body:
label: Version
description: What version of the API where you using when you noticed the bug?
options:
- v1
- v2
- v3 (Default)
- v3
- v4 (Default)
- dev (Edge)
validations:
required: true
Expand Down
4 changes: 2 additions & 2 deletions i18n/litcal.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-01-22 06:46+0000\n"
"POT-Creation-Date: 2025-01-25 15:28+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -801,7 +801,7 @@ msgid ""
"on %4$s, is suppressed by the Sunday or Solemnity %5$s in the year %6$d"
msgstr ""

#: src/Paths/Calendar.php:4654
#: src/Paths/Calendar.php:4653
#, php-format
msgid "Error receiving or parsing info from github about latest release: %s."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion src/FestivityCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@ public function getFestivitiesCollection(): array
if (empty($this->festivitiesCollection)) {
$festivitiesCollection = [];
foreach ($this->festivities as $key => $festivity) {
$gradeAbbr = $this->LitGrade->i18n($festivity->grade, false, true);
//$gradeAbbr = $this->LitGrade->i18n($festivity->grade, false, true);
$festivityAssocArr = [
"event_key" => $key,
...json_decode(json_encode($festivity), true)
Expand Down
69 changes: 34 additions & 35 deletions src/Paths/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*/
class Calendar
{
public const API_VERSION = '4.1';
public const API_VERSION = '4.2';
public static Core $Core;

private string $CacheDuration = "";
Expand Down Expand Up @@ -4475,64 +4475,63 @@ private function produceIcal(\stdClass $SerializeableLitCal, \stdClass $GitHubRe
foreach ($SerializeableLitCal->litcal as $FestivityKey => $CalEvent) {
$displayGrade = "";
$displayGradeHTML = "";
if ($CalEvent->display_grade !== null) {
$displayGrade = $CalEvent->display_grade;
if ($CalEvent['grade_display'] !== null) {
$displayGrade = $CalEvent['grade_display'];
}
if ($FestivityKey === 'DedicationLateran') {
if ($FestivityKey === 'DedicationLateran' || $FestivityKey === 'DedicationLateran_vigil') {
$displayGradeHTML = $this->LitGrade->i18n(LitGrade::FEAST, true);
} elseif (FestivityCollection::dateIsNotSunday($CalEvent->date)) {
if ($CalEvent->grade_display !== null && $CalEvent->grade_display !== "") {
$displayGradeHTML = '<B>' . $CalEvent->grade_display . '</B>';
} else {
$displayGradeHTML = $this->LitGrade->i18n($CalEvent->grade, true);
}
} elseif ((int)$CalEvent->grade === LitGrade::SOLEMNITY) {
if ($CalEvent->grade_display !== null && $CalEvent->grade_display !== "") {
$displayGradeHTML = '<B>' . $CalEvent->grade_display . '</B>';
} elseif ($CalEvent['grade_display'] === null) {
$displayGradeHTML = $this->LitGrade->i18n((int)$CalEvent['grade'], true);
} else {
if ($CalEvent['grade_display'] === '') {
$displayGradeHTML = '';
} elseif ((int)$CalEvent['grade'] >= LitGrade::FEAST) {
$displayGradeHTML = '<B>' . $CalEvent['grade_display'] . '</B>';
} else {
$displayGradeHTML = $this->LitGrade->i18n($CalEvent->grade, true);
$displayGradeHTML = $CalEvent['grade_display'];
}
}

$description = $this->LitCommon->c($CalEvent->common);
$description = $this->LitCommon->c($CalEvent['common']);
$description .= '\n' . $displayGrade;
$description .= (is_string($CalEvent->color) && $CalEvent->color != "")
|| (is_array($CalEvent->color) && count($CalEvent->color) > 0 )
? '\n' . Utilities::parseColorString($CalEvent->color, $this->CalendarParams->Locale, false)
$description .= (is_string($CalEvent['color']) && $CalEvent['color'] != "")
|| (is_array($CalEvent['color']) && count($CalEvent['color']) > 0 )
? '\n' . Utilities::parseColorString($CalEvent['color'], $this->CalendarParams->Locale, false)
: "";
$description .= property_exists($CalEvent, 'liturgical_year')
&& $CalEvent->liturgical_year !== null
&& $CalEvent->liturgical_year != ""
? '\n' . $CalEvent->liturgical_year
$description .= isset($CalEvent['liturgical_year'])
&& $CalEvent['liturgical_year'] !== null
&& $CalEvent['liturgical_year'] != ""
? '\n' . $CalEvent['liturgical_year']
: "";
$htmlDescription = "<P DIR=LTR>" . $this->LitCommon->c($CalEvent->common);
$htmlDescription = "<P DIR=LTR>" . $this->LitCommon->c($CalEvent['common']);
$htmlDescription .= '<BR>' . $displayGradeHTML;
$htmlDescription .= (is_string($CalEvent->color) && $CalEvent->color != "")
|| (is_array($CalEvent->color) && count($CalEvent->color) > 0 )
? "<BR>" . Utilities::parseColorString($CalEvent->color, $this->CalendarParams->Locale, true)
$htmlDescription .= (is_string($CalEvent['color']) && $CalEvent['color'] != "")
|| (is_array($CalEvent['color']) && count($CalEvent['color']) > 0 )
? "<BR>" . Utilities::parseColorString($CalEvent['color'], $this->CalendarParams->Locale, true)
: "";
$htmlDescription .= property_exists($CalEvent, 'liturgical_year')
&& $CalEvent->liturgical_year !== null
&& $CalEvent->liturgical_year != ""
? '<BR>' . $CalEvent->liturgical_year . "</P>"
$htmlDescription .= isset($CalEvent['liturgical_year'])
&& $CalEvent['liturgical_year'] !== null
&& $CalEvent['liturgical_year'] != ""
? '<BR>' . $CalEvent['liturgical_year'] . "</P>"
: "</P>";
$ical .= "BEGIN:VEVENT\r\n";
$ical .= "CLASS:PUBLIC\r\n";
$ical .= "DTSTART;VALUE=DATE:" . $CalEvent->date->format('Ymd') . "\r\n";// . "T" . $CalEvent->date->format( 'His' ) . "Z\r\n";
//$CalEvent->date->add( new \DateInterval( 'P1D' ) );
//$ical .= "DTEND:" . $CalEvent->date->format( 'Ymd' ) . "T" . $CalEvent->date->format( 'His' ) . "Z\r\n";
$icalDate = \DateTime::createFromFormat('U', $CalEvent['date'], new \DateTimeZone('UTC'));
$ical .= "DTSTART;VALUE=DATE:" . $icalDate->format('Ymd') . "\r\n";// . "T" . $icalDate->format( 'His' ) . "Z\r\n";
//$CalEvent['date']->add( new \DateInterval( 'P1D' ) );
//$ical .= "DTEND:" . $icalDate->format( 'Ymd' ) . "T" . $icalDate->format( 'His' ) . "Z\r\n";
$ical .= "DTSTAMP:" . date('Ymd') . "T" . date('His') . "Z\r\n";
/** The event created in the calendar is specific to this year, next year it may be different.
* So UID must take into account the year
* Next year's event should not cancel this year's event, they are different events
**/
$ical .= "UID:" . md5("LITCAL-" . $FestivityKey . '-' . $CalEvent->date->format('Y')) . "\r\n";
$ical .= "UID:" . md5("LITCAL-" . $FestivityKey . '-' . $icalDate->format('Y')) . "\r\n";
$ical .= "CREATED:" . str_replace(':', '', str_replace('-', '', $publishDate)) . "\r\n";
$desc = "DESCRIPTION:" . str_replace(',', '\,', $description);
$ical .= strlen($desc) > 75 ? rtrim(chunk_split($desc, 71, "\r\n\t")) . "\r\n" : "$desc\r\n";
$ical .= "LAST-MODIFIED:" . str_replace(':', '', str_replace('-', '', $publishDate)) . "\r\n";
$summaryLang = ";LANGUAGE=" . strtolower(preg_replace('/_/', '-', $this->CalendarParams->Locale));
$summary = "SUMMARY" . $summaryLang . ":" . str_replace(',', '\,', str_replace("\r\n", " ", $CalEvent->name));
$summary = "SUMMARY" . $summaryLang . ":" . str_replace(',', '\,', str_replace("\r\n", " ", $CalEvent['name']));
$ical .= strlen($summary) > 75 ? rtrim(chunk_split($summary, 75, "\r\n\t")) . "\r\n" : $summary . "\r\n";
$ical .= "TRANSP:TRANSPARENT\r\n";
$ical .= "X-MICROSOFT-CDO-ALLDAYEVENT:TRUE\r\n";
Expand Down

0 comments on commit 42e233f

Please sign in to comment.