Addressing bug 1257:

Changed the handling of time display format; now it's read from the language
file by default, and a new preference has been added to allow each user to
manually specify his preferred time format.
This commit is contained in:
defacer 2004-04-22 09:02:23 +00:00
parent c867774d76
commit 1b0ebe79b1
4 changed files with 59 additions and 1 deletions

View File

@ -50,6 +50,8 @@ define ('SECS_IN_DAY', 86400);
define ('CALENDAR_UPCOMING_DAYS', 14);
define ('CALENDAR_UPCOMING_MAXEVENTS', 10);
define ('CALENDAR_URL', $CFG->wwwroot.'/calendar/');
define ('CALENDAR_TF_24', '%H:%M');
define ('CALENDAR_TF_12', '%I:%M %p');
function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_year = false) {
global $CFG, $USER;
@ -674,7 +676,13 @@ function calendar_day_representation($tstamp, $now = false, $usecommonwords = tr
}
function calendar_time_representation($time) {
return userdate($time, '%H:%M');
static $langtimeformat = NULL;
if($langtimeformat === NULL) {
$langtimeformat = get_string('strftimetime');
}
$timeformat = get_user_preferences('calendar_timeformat');
// The ? is needed because the preference might be present, but empty
return userdate($time, empty($timeformat) ? $langtimeformat : $timeformat);
}
function calendar_get_link_href($linkbase, $d, $m, $y) {
@ -1160,6 +1168,7 @@ function calendar_preferences_array() {
'startwday' => get_string('pref_startwday', 'calendar'),
'maxevents' => get_string('pref_maxevents', 'calendar'),
'lookahead' => get_string('pref_lookahead', 'calendar'),
'timeformat' => get_string('pref_timeformat', 'calendar'),
);
}

View File

@ -66,6 +66,18 @@
if($_GET['commit']) {
switch($_GET['edit']) {
case 'timeformat':
if($_GET['timeformat'] == '12') {
$timeformat = CALENDAR_TF_12;
}
else if($_GET['timeformat'] == '24') {
$timeformat = CALENDAR_TF_24;
}
else {
$timeformat = '';
}
set_user_preference('calendar_'.$_GET['edit'], $timeformat);
break;
case 'startwday':
$day = intval($_GET[$_GET['edit']]);
if($day < 0 || $day > 6) {
@ -192,6 +204,24 @@
}
switch($_GET['edit']) {
case 'timeformat':
$sel = array('default' => ' selected="selected"', '12' => '', '24' => '');
switch(get_user_preferences('calendar_timeformat', '')) {
case CALENDAR_TF_12:
$sel['12'] = $sel['default'];
$sel['default'] = '';
break;
case CALENDAR_TF_24:
$sel['24'] = $sel['default'];
$sel['default'] = '';
break;
}
echo '<td><select name="timeformat">';
echo '<option value="default"'.$sel['default'].'>'.get_string('default', 'calendar').'</option>';
echo '<option value="12"'.$sel['12'].'>'.get_string('timeformat_12', 'calendar').'</option>';
echo '<option value="24"'.$sel['24'].'>'.get_string('timeformat_24', 'calendar').'</option>';
echo '</select></td>';
break;
case 'startwday':
echo '<td>';
$days = array(
@ -227,6 +257,17 @@
get_string('thursday', 'calendar'), get_string('friday', 'calendar'),
get_string('saturday', 'calendar'));
$values['startwday'] = $days[$values['startwday']];
switch($values['timeformat']) {
case '':
$values['timeformat'] = get_string('default', 'calendar');
break;
case CALENDAR_TF_12:
$values['timeformat'] = get_string('timeformat_12', 'calendar');
break;
case CALENDAR_TF_24:
$values['timeformat'] = get_string('timeformat_24', 'calendar');
break;
}
// OK, display them
foreach($prefs as $name => $description) {

View File

@ -33,6 +33,7 @@ $string['expired'] = '
$string['explain_lookahead'] = 'Ο αριθμός αυτός καθορίζει το πόσες μέρες στο μέλλον (το πολύ) πρέπει να ξεκινά κάποιο γεγονός για να ειδοποιηθείτε ότι είναι επικείμενο. Γεγονότα που ξεκινούν αργότερα στο μέλλον δεν θα εμφανίζονται ως επικείμενα. Προσέξτε ότι <strong>δεν είναι εγγυημένο</strong> ότι θα εμφανιστούν όλα τα γεγονότα στο χρονικό αυτό διάστημα, και αν είναι πάρα πολλά (περισσότερα από την προτίμησή σας \"Επικείμενα γεγονότα\") τότε τα πιο μελλοντικά δεν θα εμφανιστούν.';
$string['explain_maxevents'] = 'Ο αριθμός αυτός καθορίζει το μέγιστο αριθμό από επικείμενα γεγονότα που θα επιτρέπεται να εμφανίζεται κάθε φορά. Αν επιλέξετε πάρα πολλά, μπορεί να καταλαμβάνουν πολύ χώρο στην οθόνη.';
$string['explain_startwday'] = 'Η πρώτη μέρα της εβδομάδας καθορίζει από το ποιά μέρα θα ξεκινάει κάθε εβδομάδα οπουδήποτε βλέπετε μηνιαίο ημερολόγιο. Χρησιμοποιήστε την για να προσαρμόσετε την εμφάνιση του ημερολογίου στις προτιμήσεις σας.';
$string['explain_timeformat'] = 'Εδώ μπορείτε να επιλέξετε τη μορφή με την οποία θα εμφανίζονται οι ώρες στο ημερολόγιο. Οι επιλογές για 12ωρη και 24ωρη μορφή εμφανίζουν όλες τις ώρες στη μορφή αυτή. Με την επιλογή \"εξ\' ορισμού\" θα χρησιμοποιείται αυτόματα η μορφή απεικόνισης που έχει οριστεί για τη γλώσσα στην οποία βλέπετε τη σελίδα.';
$string['globalevents'] = 'Γεγονότα συστήματος';
$string['groupevents'] = 'Ομαδικά γεγονότα';
$string['hidden'] = 'δεν φαίνονται';
@ -44,10 +45,13 @@ $string['oneevent'] = '1
$string['pref_lookahead'] = 'Μέρες στο μέλλον';
$string['pref_maxevents'] = 'Επικείμενα γεγονότα';
$string['pref_startwday'] = 'Πρώτη μέρα εβδομάδας';
$string['pref_timeformat'] = 'Μορφή εμφάνισης ώρας';
$string['preferences'] = 'Προτιμήσεις';
$string['preferences_available'] = 'Διαθέσιμες προσωπικές προτιμήσεις';
$string['shown'] = 'φαίνονται';
$string['spanningevents'] = 'Γεγονότα σε εξέλιξη';
$string['timeformat_12'] = '12ωρη (πμ/μμ)';
$string['timeformat_24'] = '24ωρη';
$string['today'] = 'Σήμερα';
$string['tomorrow'] = 'Αύριο';
$string['tt_deleteevent'] = 'Διαγραφή γεγονότος';

View File

@ -33,6 +33,7 @@ $string['expired'] = 'Expired';
$string['explain_lookahead'] = 'This preference sets the (maximum) number of days in the future that an event has to start in in order to be displayed as an upcoming event. Events that start later in the future will never be displayed as upcoming. Please note that <strong>there is no guarantee</strong> that all events starting in this time frame will be displayed; if they are too many (more than the \"Maximum upcoming events\" preference) then the most distant events will not be displayed.';
$string['explain_maxevents'] = 'This preference sets the maximum number of upcoming events that can be displayed. If you pick a large number here, it is possible that upcoming events displays will take up a lot of space on your screen.';
$string['explain_startwday'] = 'This preference configures the way that all monthly calendars are displayed. Use it to make them be displayed in the way you are accustomed to.';
$string['explain_timeformat'] = 'This preference controls the way that times are displayed in the calendar. You can choose to see times in either 12 or 24 hour format. If you choose \"default\", then the format will be automatically chosen according to the language you use in the site.';
$string['globalevents'] = 'Global events';
$string['groupevents'] = 'Group events';
$string['hidden'] = 'hidden';
@ -44,10 +45,13 @@ $string['oneevent'] = '1 event';
$string['pref_lookahead'] = 'Upcoming events look-ahead';
$string['pref_maxevents'] = 'Maximum upcoming events';
$string['pref_startwday'] = 'First day of week';
$string['pref_timeformat'] = 'Time display format';
$string['preferences'] = 'Preferences';
$string['preferences_available'] = 'Your personal preferences';
$string['shown'] = 'shown';
$string['spanningevents'] = 'Events underway';
$string['timeformat_12'] = '12-hour (am/pm)';
$string['timeformat_24'] = '24-hour';
$string['today'] = 'Today';
$string['tomorrow'] = 'Tomorrow';
$string['tt_deleteevent'] = 'Delete event';