Skip to content

Commit

Permalink
Format: replace dateIntlReadable with dayOfWeekName and monthName whe…
Browse files Browse the repository at this point in the history
…re applicable
  • Loading branch information
SKuipers committed May 17, 2024
1 parent 974e078 commit ea08ba1
Show file tree
Hide file tree
Showing 22 changed files with 69 additions and 86 deletions.
2 changes: 1 addition & 1 deletion modules/Activities/activities_attendance.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
foreach ($activitySessions as $sessionDate => $sessionTimestamp) {
$col = $row->addColumn()->addClass('h-24 px-2 text-center');
$dateLabel = $col->addContent(
Format::dateIntlReadable($sessionDate, 'EEE') . '<br>' .
Format::dayOfWeekName($sessionDate, true) . '<br>' .
Format::dateIntlReadable($sessionDate, 'MMM d')
)->addClass('w-10 mx-auto whitespace-nowrap');

Expand Down
4 changes: 2 additions & 2 deletions modules/Activities/report_attendance.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,12 @@

printf("<span title='%s'>%s <br/> %s</span><br/>&nbsp;<br/>",
$sessionAttendanceData[$sessionDate]['info'],
Format::dateIntlReadable($sessionDate, 'EEE'),
Format::dayOfWeekName($sessionDate, true),
Format::dateIntlReadable($sessionDate, 'MMM d')
);
} else {
echo "<td style='color: #bbb; vertical-align:top; width: 50px; white-space: nowrap;'>";
echo Format::dateIntlReadable($sessionDate, 'EEE').' <br/> '.
echo Format::dayOfWeekName($sessionDate).' <br/> '.
Format::dateIntlReadable($sessionDate, 'MMM d').'<br/>&nbsp;<br/>';
}
echo '</td>';
Expand Down
4 changes: 2 additions & 2 deletions modules/Attendance/attendance.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@
'currentDate' => $day['currentDate'],
]);
$content =
'<div class="day text-xs">' . Format::dateIntlReadable($day['currentDate'], 'dd') . '</div>' .
'<div class="month text-xxs mt-px">' . Format::dateIntlReadable($day['currentDate'], 'MMM') . '</div>';
'<div class="day text-xs">' . Format::date($day['currentDate'], 'd') . '</div>' .
'<div class="month text-xxs mt-px">' . Format::monthName($day['currentDate'], true) . '</div>';
}

// determine how to display link and content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,12 @@
echo "<td class='$class' style='padding: 12px !important;' title='{$title}'>";
if ($link != '') {
echo "<a href='$link'>";
echo Format::dateIntlReadable($date, 'dd').'<br/>';
echo "<span>".Format::dateIntlReadable($date, 'MMM').'</span>';
echo Format::date($date, 'd').'<br/>';
echo "<span>".Format::monthName($date, true).'</span>';
echo '</a>';
} else {
echo Format::dateIntlReadable($date, 'dd').'<br/>';
echo "<span>".Format::dateIntlReadable($date, 'MMM').'</span>';
echo Format::date($date, 'd').'<br/>';
echo "<span>".Format::monthName($date, true).'</span>';
}
echo '</td>';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@
}

echo "<td class='$class' style='padding: 12px !important;'>";
echo Format::dateIntlReadable($lastNSchoolDays[$i], 'dd').'<br/>';
echo "<span>".Format::dateIntlReadable($lastNSchoolDays[$i], 'MMM').'</span>';
echo Format::date($lastNSchoolDays[$i], 'd').'<br/>';
echo "<span>".Format::monthName($lastNSchoolDays[$i], true).'</span>';
echo '</td>';

// Wrap to a new line every 10 dates
Expand Down
8 changes: 4 additions & 4 deletions modules/Attendance/report_formGroupsNotRegistered_byDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@
echo "<td class='$class' style='padding: 12px !important;' title='{$title}'>";
if ($link != '') {
echo "<a href='$link'>";
echo Format::dateIntlReadable($date, 'dd').'<br/>';
echo "<span>".Format::dateIntlReadable($date, 'MMM').'</span>';
echo Format::ate($date, 'd').'<br/>';
echo "<span>".Format::monthName($date, true).'</span>';
echo '</a>';
} else {
echo Format::dateIntlReadable($date, 'dd').'<br/>';
echo "<span>".Format::dateIntlReadable($date, 'MMM').'</span>';
echo Format::ate($date, 'd').'<br/>';
echo "<span>".Format::monthName($date, true).'</span>';
}
echo '</td>';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@
echo "<td class='$class' style='padding: 12px !important;'>";
if ($link != '') {
echo "<a href='$link'>";
echo Format::dateIntlReadable($lastNSchoolDays[$i], 'dd').'<br/>';
echo "<span>".Format::dateIntlReadable($lastNSchoolDays[$i], 'MMM').'</span>';
echo Format::date($lastNSchoolDays[$i], 'd').'<br/>';
echo "<span>".Format::monthName($lastNSchoolDays[$i], true).'</span>';
echo '</a>';
} else {
echo Format::dateIntlReadable($lastNSchoolDays[$i], 'dd').'<br/>';
echo "<span>".Format::dateIntlReadable($lastNSchoolDays[$i], 'MMM').'</span>';
echo Format::date($lastNSchoolDays[$i], 'd').'<br/>';
echo "<span>".Format::monthName($lastNSchoolDays[$i], true).'</span>';
}
echo '</td>';
}
Expand Down
4 changes: 2 additions & 2 deletions modules/Attendance/src/AttendanceView.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ public function renderMiniHistory($gibbonPersonID, $context, $gibbonCourseClassI

$output .= '<td class="' . $class . '">';
$output .= '<a href="' . $link . '" title="' . $linkTitle . '">';
$output .= Format::dateIntlReadable($currentDay, 'dd') . '<br/>';
$output .= '<span>' . Format::dateIntlReadable($currentDay, 'MMM') . '</span>';
$output .= Format::date($currentDay, 'd') . '<br/>';
$output .= '<span>' . Format::monthName($currentDay, true) . '</span>';
$output .= '</a>';
$output .= '</td>';
}
Expand Down
2 changes: 1 addition & 1 deletion modules/Formal Assessment/moduleFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ function externalAssessmentDetails($guid, $gibbonPersonID, $connection2, $gibbon
} else {
while ($rowAssessments = $resultAssessments->fetch()) {
echo '<h2>';
echo __($rowAssessments['name'])." <span style='font-size: 75%; font-style: italic'>(".Format::monthName(mktime(0, 0, 0, substr($rowAssessments['date'], 5, 2))).' '.substr($rowAssessments['date'], 0, 4).')</span>';
echo __($rowAssessments['name'])." <span style='font-size: 75%; font-style: italic'>(".Format::monthName(mktime(0, 0, 0, substr($rowAssessments['date'], 5, 2)), true).' '.substr($rowAssessments['date'], 0, 4).')</span>';
if ($manage == true) {
echo "<a href='".$session->get('absoluteURL').'/index.php?q=/modules/'.$session->get('module')."/externalAssessment_manage_details_edit.php&gibbonPersonID=$gibbonPersonID&gibbonExternalAssessmentStudentID=".$rowAssessments['gibbonExternalAssessmentStudentID']."&search=$search&allStudents=$allStudents'><img style='margin-left: 5px' title='".__('Edit')."' src='./themes/".$session->get('gibbonThemeName')."/img/config.png'/></a> ";
echo "<a href='".$session->get('absoluteURL').'/fullscreen.php?q=/modules/'.$session->get('module')."/externalAssessment_manage_details_delete.php&gibbonPersonID=$gibbonPersonID&gibbonExternalAssessmentStudentID=".$rowAssessments['gibbonExternalAssessmentStudentID']."&search=$search&allStudents=$allStudents&width=600&height=135' class='thickbox'><img title='".__('Delete')."' src='./themes/".$session->get('gibbonThemeName')."/img/garbage.png'/></a>";
Expand Down
6 changes: 3 additions & 3 deletions modules/Planner/planner.php
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@
echo '<td>';
if (!(is_null($row['date']))) {
echo '<b>'.Format::date($row['date']).'</b><br/>';
echo Format::dayOfWeekName(strtotime($row['date']));
echo Format::dayOfWeekName($row['date']);
}
echo '</td>';
echo '<td>';
Expand Down Expand Up @@ -1008,8 +1008,8 @@
echo "</td>";
echo "<td $style>";
echo '<b>'.Format::date($lesson['1']).'</b><br/>';
echo Format::dayOfWeekName(strtotime($lesson['1']), '%A').'<br/>';
echo Format::monthName(strtotime($lesson['1']), '%B').'<br/>';
echo Format::dayOfWeekName($lesson['1']).'<br/>';
echo Format::monthName($lesson['1']).'<br/>';
if ($lesson[8] == 'Timing Change') {
echo '<u>'.$lesson[8].'</u><br/><i>('.substr($lesson[9], 0, 5).'-'.substr($lesson[10], 0, 5).')</i>';
}
Expand Down
2 changes: 1 addition & 1 deletion modules/Staff/coverage_my.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
$table->addColumn('date', __('Date'))
->format(Format::using('dateIntlReadable', 'date'))
->formatDetails(function ($coverage) {
return Format::small(Format::dateIntlReadable($coverage['date'], 'EEEE'));
return Format::small(Format::dayOfWeekName($coverage['date']));
});

$table->addColumn('period', __('Period'))
Expand Down
5 changes: 3 additions & 2 deletions modules/Staff/coverage_planner.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@

$gibbonSchoolYearID = $session->get('gibbonSchoolYearID');
$dateFormat = $session->get('i18n')['dateFormatPHP'];
$date = isset($_REQUEST['date'])? DateTimeImmutable::createFromFormat($dateFormat, $_REQUEST['date']) :new DateTimeImmutable();

$date = !empty($_REQUEST['date'])? DateTimeImmutable::createFromFormat($dateFormat, $_REQUEST['date']) : new DateTimeImmutable();

$urgencyThreshold = $container->get(SettingGateway::class)->getSettingByScope('Staff', 'urgencyThreshold');
$staffCoverageGateway = $container->get(StaffCoverageGateway::class);
Expand Down Expand Up @@ -94,7 +95,7 @@
->addClass('thickbox float-right mt-8')
->getOutput();

echo '<h2>'.__(Format::dateIntlReadable($date->format('Y-m-d'), 'EEEE')).'</h2>';
echo '<h2>'.__(Format::dayOfWeekName($date->format('Y-m-d'))).'</h2>';
echo '<p>'.Format::dateIntlReadable($date->format('Y-m-d')).'</p>';

foreach ($times as $groupBy => $timeSlot) {
Expand Down
4 changes: 2 additions & 2 deletions modules/Staff/report_absences_summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
}

$calendar[] = [
'name' => Format::dateIntlReadable($monthDate->format('Y-m-d'), 'MMM'),
'name' => Format::monthName($monthDate->format('Y-m-d'), true),
'days' => $days,
];
}
Expand Down Expand Up @@ -173,7 +173,7 @@
if (empty($day)) return '';
$dateText = $day['date']->format($dateFormat);
$url = $baseURL.'&dateStart='.$dateText.'&dateEnd='.$dateText.'&gibbonStaffAbsenceTypeID='.$gibbonStaffAbsenceTypeID;
$title = Format::dateIntlReadable($day['date'], 'EEEE');
$title = Format::dayOfWeekName($day['date']);
$title .= '<br/>'.Format::dateIntlReadable($day['date'], 'MMM d, yyyy');
if ($day['count'] > 0) {
$title .= '<br/>'.__n('{count} Absence', '{count} Absences', $day['count']);
Expand Down
4 changes: 2 additions & 2 deletions modules/Staff/report_absences_weekly.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@
}

if (!isSchoolOpen($guid, $date->format('Y-m-d'), $connection2)) {
echo '<h2>'.__(Format::dateIntlReadable($date->format('Y-m-d'), 'EEEE')).'</h2>';
echo '<h2>'.__(Format::dayOfWeekName($date->format('Y-m-d'))).'</h2>';
echo Format::alert(__('School is closed on the specified day.'));
continue;
}

$table = DataTable::create('staffAbsences'.$date->format('D'));
$table->setTitle(__(Format::dateIntlReadable($date->format('Y-m-d'), 'EEEE')));
$table->setTitle(__(Format::dayOfWeekName($date->format('Y-m-d'))));
$table->setDescription(Format::dateIntlReadable($date->format('Y-m-d')));

$canView = isActionAccessible($guid, $connection2, '/modules/Staff/absences_view_byPerson.php', 'View Absences_any');
Expand Down
2 changes: 1 addition & 1 deletion modules/Staff/report_coverage_summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@

$count = 0;
foreach ($dateRange as $monthDate) {
$table->addColumn('month'.$count, Format::dateIntlReadable($monthDate, 'MMM'))->description(Format::dateIntlReadable($monthDate, 'yyyy'))
$table->addColumn('month'.$count, Format::monthName($monthDate, true))->description(Format::dateIntlReadable($monthDate, 'yyyy'))
->notSortable()
->format(function ($sub) use ($monthDate) {
$sum = array_sum($sub['coverage'][$monthDate->format('Y-m')] ?? []);
Expand Down
2 changes: 1 addition & 1 deletion modules/Staff/src/Forms/CoverageRequestForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public function createForm($gibbonPersonID, $dateStart, $dateEnd, $allDay, $time
$table->addColumn('dateLabel', __('Date'))
->format(Format::using('dateIntlReadable', 'date'))
->formatDetails(function ($coverage) {
return Format::small(Format::dateIntlReadable($coverage['date'], 'EEEE'));
return Format::small(Format::dayOfWeekName($coverage['date']));
});

if ($coverageByTimetable) {
Expand Down
4 changes: 2 additions & 2 deletions modules/Staff/src/Tables/AbsenceCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static function create($absences, $dateStart, $dateEnd)
}

$calendar[] = [
'name' => Format::dateIntlReadable($month ,'MMM'),
'name' => Format::monthName($month, true),
'days' => $days,
];
}
Expand All @@ -88,7 +88,7 @@ public static function create($absences, $dateStart, $dateEnd)
if (empty($day) || $day['count'] <= 0) return '';

$url = 'fullscreen.php?q=/modules/Staff/absences_view_details.php&gibbonStaffAbsenceID='.$day['absence']['gibbonStaffAbsenceID'].'&width=800&height=550';
$title = Format::dateIntlReadable($day['date'], 'EEEE').'<br/>'.Format::dateIntlReadable($day['date'], 'MMM d, yyyy');
$title = Format::dayOfWeekName($day['date']).'<br/>'.Format::dateIntlReadable($day['date'], 'MMM d, yyyy');
$title .= '<br/>'.$day['absence']['type'];
$classes = ['thickbox'];
if ($day['absence']['allDay'] == 'N') {
Expand Down
4 changes: 2 additions & 2 deletions modules/Staff/src/Tables/CoverageCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static function create($coverage, $exceptions, $dateStart, $dateEnd)
}

$calendar[] = [
'name' => Format::dateIntlReadable($month ,'MMM'),
'name' => Format::monthName($month, true),
'days' => $days,
];
}
Expand Down Expand Up @@ -107,7 +107,7 @@ public static function create($coverage, $exceptions, $dateStart, $dateEnd)

$url = 'fullscreen.php?q=/modules/Staff/coverage_view_details.php&gibbonStaffCoverageID='.$coverage['gibbonStaffCoverageID'].'&width=800&height=550';

$params['title'] = Format::dateIntlReadable($day['date'], 'EEEE').'<br/>'.Format::dateIntlReadable($day['date'], 'MMM d, yyyy');
$params['title'] = Format::dayOfWeekName($day['date']).'<br/>'.Format::dateIntlReadable($day['date'], 'MMM d, yyyy');
$params['class'] = '';
if ($coverage['allDay'] == 'N') {
$params['class'] = $coverage['timeStart'] < '12:00:00' ? 'half-day-am' : 'half-day-pm';
Expand Down
2 changes: 1 addition & 1 deletion modules/Staff/src/Tables/CoverageDates.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected function createFromDates($status, $dates) {
$table->addColumn('date', __('Date'))
->format(Format::using('dateIntlReadable', 'date'))
->formatDetails(function ($coverage) {
return Format::small(Format::dateIntlReadable($coverage['date'], 'EEEE'));
return Format::small(Format::dayOfWeekName($coverage['date']));
});

if ($coverageByTimetable) {
Expand Down
2 changes: 1 addition & 1 deletion modules/Timetable/moduleFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2367,7 +2367,7 @@ function renderTTSpace($guid, $connection2, $gibbonSpaceID, $gibbonTTID, $title
$output .= __($day['nameShort']).'<br/>';
}
else {
$output .= ($rowDay['nameShort'] ?? Format::dayOfWeekName($startDayStamp + (86400 * $dateCorrection))).'<br/>';
$output .= ($rowDay['nameShort'] ?? Format::dayOfWeekName(date('Y-m-d', $startDayStamp + (86400 * $dateCorrection)))).'<br/>';
}
$output .= "<span style='font-size: 80%; font-style: italic'>".date($session->get('i18n')['dateFormatPHP'], ($startDayStamp + (86400 * $dateCorrection))).'</span><br/>';
try {
Expand Down
Loading

0 comments on commit ea08ba1

Please sign in to comment.