Skip to content

Commit

Permalink
Merge pull request #194 from Liturgical-Calendar/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
JohnRDOrazio committed Apr 9, 2024
2 parents 8901d97 + 05efc8d commit 311ec30
Show file tree
Hide file tree
Showing 29 changed files with 1,874 additions and 1,180 deletions.
30 changes: 16 additions & 14 deletions DateOfEaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
ini_set('date.timezone', 'Europe/Vatican');

include_once( 'includes/enums/LitLocale.php' );
$AvailableLocales = array_filter(ResourceBundle::getLocales(''), function ($value) {
return strpos($value, '_') === false;
});

$LOCALE = isset($_GET["locale"]) && in_array( strtolower($_GET["locale"]), $AvailableLocales) ? strtoupper($_GET["locale"]) : LitLocale::LATIN;
$LOCALE = isset($_GET["locale"]) && LitLocale::isValid($_GET["locale"]) ? $_GET["locale"] : LitLocale::LATIN;

if(file_exists('engineCache/easter/' . $LOCALE . '.json') ){
header('Content-Type: application/json');
Expand All @@ -20,16 +16,22 @@
include_once( 'includes/LitFunc.php' );
include_once( 'includes/LitMessages.php' );

$baseLocale = Locale::getPrimaryLanguage($LOCALE);
$localeArray = [
strtolower( $LOCALE ) . '_' . $LOCALE . '.utf8',
strtolower( $LOCALE ) . '_' . $LOCALE . '.UTF-8',
strtolower( $LOCALE ) . '_' . $LOCALE,
strtolower( $LOCALE )
$LOCALE . '.utf8',
$LOCALE . '.UTF-8',
$LOCALE,
$baseLocale . '_' . strtoupper( $baseLocale ) . '.utf8',
$baseLocale . '_' . strtoupper( $baseLocale ) . '.UTF-8',
$baseLocale . '_' . strtoupper( $baseLocale ),
$baseLocale . '.utf8',
$baseLocale . '.UTF-8',
$baseLocale
];
setlocale( LC_ALL, $localeArray );
$dayOfTheWeekDayMonthYear = IntlDateFormatter::create( strtolower( $LOCALE ), IntlDateFormatter::FULL, IntlDateFormatter::NONE, 'UTC', IntlDateFormatter::GREGORIAN, "EEEE d MMMM yyyy" );
$dayMonthYear = IntlDateFormatter::create( strtolower( $LOCALE ), IntlDateFormatter::FULL, IntlDateFormatter::NONE, 'UTC', IntlDateFormatter::GREGORIAN, "d MMMM yyyy" );
$dayOfTheWeek = IntlDateFormatter::create( strtolower( $LOCALE ), IntlDateFormatter::FULL, IntlDateFormatter::NONE, 'UTC', IntlDateFormatter::GREGORIAN, "EEEE" );
$dayOfTheWeekDayMonthYear = IntlDateFormatter::create( $LOCALE, IntlDateFormatter::FULL, IntlDateFormatter::NONE, 'UTC', IntlDateFormatter::GREGORIAN, "EEEE d MMMM yyyy" );
$dayMonthYear = IntlDateFormatter::create( $LOCALE, IntlDateFormatter::FULL, IntlDateFormatter::NONE, 'UTC', IntlDateFormatter::GREGORIAN, "d MMMM yyyy" );
$dayOfTheWeek = IntlDateFormatter::create( $LOCALE, IntlDateFormatter::FULL, IntlDateFormatter::NONE, 'UTC', IntlDateFormatter::GREGORIAN, "EEEE" );

$EasterDates = new stdClass();
$EasterDates->DatesArray = [];
Expand All @@ -52,7 +54,7 @@
$gregDateString = "";
$julianDateString = "";
$westernJulianDateString = "";
switch ($LOCALE) {
switch (strtoupper($baseLocale)) {
case LitLocale::LATIN:
$month = (int)$gregorian_easter->format('n'); //n = 1-January to 12-December
$monthLatin = LitMessages::LATIN_MONTHS[$month];
Expand All @@ -64,7 +66,7 @@
$monthLatin = LitMessages::LATIN_MONTHS[$month];
$westernJulianDateString = 'Dies Domini, ' . $western_julian_easter->format('j') . ' ' . $monthLatin . ' ' . $western_julian_easter->format('Y');
break;
case LitLocale::ENGLISH:
case 'EN':
$gregDateString = $gregorian_easter->format('l, F jS, Y');
$julianDateString = 'Sunday' . $julian_easter->format(', F jS, Y');
$westernJulianDateString = $western_julian_easter->format('l, F jS, Y');
Expand Down
5 changes: 2 additions & 3 deletions LitCalAllFestivities.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
return str_starts_with( $item, "VATICAN_" );
});

$LOCALE = isset( $_GET["locale"] ) ? $_GET["locale"] : "la";
$LOCALE = LitLocale::isValid( $LOCALE ) ? $LOCALE : "la";
$LOCALE = $LOCALE !== "LA" && $LOCALE !== "la" ? LOCALE::getPrimaryLanguage( $LOCALE ) : "la";
$LOCALE = isset( $_GET["locale"] ) && LitLocale::isValid( $_GET["locale"] ) ? $_GET["locale"] : "la";
$LOCALE = $LOCALE !== "LA" && $LOCALE !== "la" ? Locale::getPrimaryLanguage( $LOCALE ) : "la";

foreach( $LatinMissals as $LatinMissal ) {
$DataFile = RomanMissal::getSanctoraleFileName( $LatinMissal );
Expand Down
12 changes: 5 additions & 7 deletions LitCalHealth.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ private function executeValidation( object $validation, ConnectionInterface $to

private function validateCalendar( string $Calendar, int $Year, string $category, ConnectionInterface $to ) : void {
if( $Calendar === 'VATICAN' ) {
$req = "?year=$Year";
$req = "?nationalcalendar=VATICAN&year=$Year&calendartype=CIVIL";
} else {
$req = "?$category=$Calendar&year=$Year";
$req = "?$category=$Calendar&year=$Year&calendartype=CIVIL";
}
$data = file_get_contents( self::LitCalBaseUrl . $req );
if( $data !== false ) {
Expand Down Expand Up @@ -228,9 +228,9 @@ private function validateCalendar( string $Calendar, int $Year, string $category

private function executeUnitTest( string $Test, string $Calendar, int $Year, string $category, ConnectionInterface $to ) : void {
if( $Calendar === 'VATICAN' ) {
$req = "?year=$Year";
$req = "?nationalcalendar=VATICAN&year=$Year&calendartype=CIVIL";
} else {
$req = "?$category=$Calendar&year=$Year";
$req = "?$category=$Calendar&year=$Year&calendartype=CIVIL";
}
$jsonData = json_decode( file_get_contents( self::LitCalBaseUrl . $req ) );
if( json_last_error() === JSON_ERROR_NONE ) {
Expand All @@ -248,6 +248,7 @@ private function executeUnitTest( string $Test, string $Calendar, int $Year, str
else if( gettype( $testResult ) === 'object' ) {
$testResult->classes = ".$Test.year-{$Year}.test-valid";
$testResult->test = $Test;
$testResult->jsonData = $jsonData;
$this->sendMessage( $to, $testResult );
}
}
Expand All @@ -269,6 +270,3 @@ private function validateDataAgainstSchema( object|array $data, string $schemaUr
}

}


$LitCalHealth = new LitCalHealth();
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<table>
<thead>
<tr><th colspan="2">Code quality</th><th>Translation status</th></tr>
<tr><th style="text-align:center;"><a href="https://github.com/Liturgical-Calendar/LiturgicalCalendarAPI/tree/master">main branch</a></th><th style="text-align:center;"><a href="https://github.com/Liturgical-Calendar/LiturgicalCalendarAPI/tree/development">development branch</a></th><th></th></tr>
<tr><th colspan="2">Code quality</th><th>Translation status</th><th>OpenAPI validation</th></tr>
<tr><th style="text-align:center;"><a href="https://github.com/Liturgical-Calendar/LiturgicalCalendarAPI/tree/master">main branch</a></th><th style="text-align:center;"><a href="https://github.com/Liturgical-Calendar/LiturgicalCalendarAPI/tree/development">development branch</a></th><th></th><th></th></tr>
</thead>
<tbody>
<tr>
Expand All @@ -14,6 +14,7 @@
<td><a href="https://translate.johnromanodorazio.com/engage/liturgical-calendar/">
<img src="https://translate.johnromanodorazio.com/widgets/liturgical-calendar/-/287x66-white.png" alt="Translation status" />
</a></td>
<td> <a href="https://validator.swagger.io/validator?url=https://raw.githubusercontent.com/Liturgical-Calendar/LiturgicalCalendarAPI/master/schemas/openapi.json"><img src="https://validator.swagger.io/validator?url=https://raw.githubusercontent.com/Liturgical-Calendar/LiturgicalCalendarAPI/master/schemas/openapi.json" alt="OpenAPI validation result" /></a></td>
</tr>
</tbody>
</table>
Expand Down
Loading

0 comments on commit 311ec30

Please sign in to comment.