Changeset 3479297
- Timestamp:
- 03/10/2026 05:13:59 PM (3 weeks ago)
- Location:
- esolleso-daily-bible-reading-plan
- Files:
-
- 2 edited
-
tags/1.1.0/includes/helpers.php (modified) (1 diff)
-
trunk/includes/helpers.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
esolleso-daily-bible-reading-plan/tags/1.1.0/includes/helpers.php
r3479283 r3479297 24 24 } 25 25 26 // Use IntlDateFormatter for localized Georgian text 27 $formatter = new IntlDateFormatter( 28 $lang === 'geo' ? 'ka_GE' : 'en', 29 IntlDateFormatter::FULL, 30 IntlDateFormatter::NONE, 31 'UTC', 32 IntlDateFormatter::GREGORIAN, 33 'EEEE, d MMMM, y' 34 ); 35 36 return $formatter->format($date); 26 // Prefer IntlDateFormatter when the intl extension is available. 27 if (class_exists('\IntlDateFormatter')) { 28 $formatter = new \IntlDateFormatter( 29 $lang === 'geo' ? 'ka_GE' : 'en', 30 \IntlDateFormatter::FULL, 31 \IntlDateFormatter::NONE, 32 'UTC', 33 \IntlDateFormatter::GREGORIAN, 34 'EEEE, d MMMM, y' 35 ); 36 37 return $formatter->format($date); 38 } 39 40 // Fallback when intl extension is missing: simple manual formatting. 41 $locale = ($lang === 'geo') ? 'geo' : 'eng'; 42 43 $days = [ 44 'eng' => [ 45 1 => 'Monday', 46 2 => 'Tuesday', 47 3 => 'Wednesday', 48 4 => 'Thursday', 49 5 => 'Friday', 50 6 => 'Saturday', 51 7 => 'Sunday', 52 ], 53 'geo' => [ 54 1 => 'ორშაბათი', 55 2 => 'სამშაბათი', 56 3 => 'ოთხშაბათი', 57 4 => 'ხუთშაბათი', 58 5 => 'პარასკევი', 59 6 => 'შაბათი', 60 7 => 'კვირა', 61 ], 62 ]; 63 64 $months = [ 65 'eng' => [ 66 1 => 'January', 67 2 => 'February', 68 3 => 'March', 69 4 => 'April', 70 5 => 'May', 71 6 => 'June', 72 7 => 'July', 73 8 => 'August', 74 9 => 'September', 75 10 => 'October', 76 11 => 'November', 77 12 => 'December', 78 ], 79 'geo' => [ 80 1 => 'იანვარი', 81 2 => 'თებერვალი', 82 3 => 'მარტი', 83 4 => 'აპრილი', 84 5 => 'მაისი', 85 6 => 'ივნისი', 86 7 => 'ივლისი', 87 8 => 'აგვისტო', 88 9 => 'სექტემბერი', 89 10 => 'ოქტომბერი', 90 11 => 'ნოემბერი', 91 12 => 'დეკემბერი', 92 ], 93 ]; 94 95 $dayOfWeek = (int) $date->format('N'); // 1 (Mon) - 7 (Sun) 96 $month = (int) $date->format('n'); // 1 - 12 97 $day = (int) $date->format('j'); 98 99 $dayName = $days[$locale][$dayOfWeek] ?? $date->format('l'); 100 $monthName = $months[$locale][$month] ?? $date->format('F'); 101 102 return sprintf('%s, %d %s, %s', $dayName, $day, $monthName, $year); 37 103 } 38 104 -
esolleso-daily-bible-reading-plan/trunk/includes/helpers.php
r3479283 r3479297 24 24 } 25 25 26 // Use IntlDateFormatter for localized Georgian text 27 $formatter = new IntlDateFormatter( 28 $lang === 'geo' ? 'ka_GE' : 'en', 29 IntlDateFormatter::FULL, 30 IntlDateFormatter::NONE, 31 'UTC', 32 IntlDateFormatter::GREGORIAN, 33 'EEEE, d MMMM, y' 34 ); 35 36 return $formatter->format($date); 26 // Prefer IntlDateFormatter when the intl extension is available. 27 if (class_exists('\IntlDateFormatter')) { 28 $formatter = new \IntlDateFormatter( 29 $lang === 'geo' ? 'ka_GE' : 'en', 30 \IntlDateFormatter::FULL, 31 \IntlDateFormatter::NONE, 32 'UTC', 33 \IntlDateFormatter::GREGORIAN, 34 'EEEE, d MMMM, y' 35 ); 36 37 return $formatter->format($date); 38 } 39 40 // Fallback when intl extension is missing: simple manual formatting. 41 $locale = ($lang === 'geo') ? 'geo' : 'eng'; 42 43 $days = [ 44 'eng' => [ 45 1 => 'Monday', 46 2 => 'Tuesday', 47 3 => 'Wednesday', 48 4 => 'Thursday', 49 5 => 'Friday', 50 6 => 'Saturday', 51 7 => 'Sunday', 52 ], 53 'geo' => [ 54 1 => 'ორშაბათი', 55 2 => 'სამშაბათი', 56 3 => 'ოთხშაბათი', 57 4 => 'ხუთშაბათი', 58 5 => 'პარასკევი', 59 6 => 'შაბათი', 60 7 => 'კვირა', 61 ], 62 ]; 63 64 $months = [ 65 'eng' => [ 66 1 => 'January', 67 2 => 'February', 68 3 => 'March', 69 4 => 'April', 70 5 => 'May', 71 6 => 'June', 72 7 => 'July', 73 8 => 'August', 74 9 => 'September', 75 10 => 'October', 76 11 => 'November', 77 12 => 'December', 78 ], 79 'geo' => [ 80 1 => 'იანვარი', 81 2 => 'თებერვალი', 82 3 => 'მარტი', 83 4 => 'აპრილი', 84 5 => 'მაისი', 85 6 => 'ივნისი', 86 7 => 'ივლისი', 87 8 => 'აგვისტო', 88 9 => 'სექტემბერი', 89 10 => 'ოქტომბერი', 90 11 => 'ნოემბერი', 91 12 => 'დეკემბერი', 92 ], 93 ]; 94 95 $dayOfWeek = (int) $date->format('N'); // 1 (Mon) - 7 (Sun) 96 $month = (int) $date->format('n'); // 1 - 12 97 $day = (int) $date->format('j'); 98 99 $dayName = $days[$locale][$dayOfWeek] ?? $date->format('l'); 100 $monthName = $months[$locale][$month] ?? $date->format('F'); 101 102 return sprintf('%s, %d %s, %s', $dayName, $day, $monthName, $year); 37 103 } 38 104
Note: See TracChangeset
for help on using the changeset viewer.