Ticket #6913: time_format_6913.diff
| File time_format_6913.diff, 7.1 kB (added by regulatethis, 5 months ago) |
|---|
-
wp-admin/includes/post.php
old new 81 81 } 82 82 } 83 83 84 // Let's handle the conversion to 24 hour time if the user has chosen 12 hour for posting 85 if( !empty( $_POST['time_format'] ) && $_POST['time_format'] == '12_hour' ) { 86 // If only the meridiem has been switched, we still need to update the time... 87 if( !empty( $_POST['hidden_meridiem'] ) && $_POST['hidden_meridiem'] != $_POST['meridiem'] ) 88 $_POST['edit_date'] = '1'; 89 90 // "Convert" hour back to 24-hour format if necessary, taking the meridiem into account... 91 if ( !empty( $_POST['time_format'] ) && $_POST['time_format'] == '12_hour' ) { 92 93 // If the user accidentally enters a 24-hour time then we implicitly fix it for him 94 $_POST['hh'] = $_POST['hh'] <= 12 ? $_POST['hh'] : $_POST['hh'] - 12; 95 96 if ( $_POST['meridiem'] == 'pm' ) { 97 $_POST['hh'] += 12; 98 } 99 } 100 } 101 84 102 if (!empty ( $_POST['edit_date'] ) ) { 85 103 $aa = $_POST['aa']; 86 104 $mm = $_POST['mm']; -
wp-admin/includes/template.php
old new 844 844 845 845 $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 ); 846 846 $post_date = ($for_post) ? $post->post_date : $comment->comment_date; 847 $time_format = get_user_option('time_format'); 848 $hour_format = $time_format == '12_hour' ? 'g' : 'H'; 847 849 $jj = ($edit) ? mysql2date( 'd', $post_date ) : gmdate( 'd', $time_adj ); 848 850 $mm = ($edit) ? mysql2date( 'm', $post_date ) : gmdate( 'm', $time_adj ); 849 851 $aa = ($edit) ? mysql2date( 'Y', $post_date ) : gmdate( 'Y', $time_adj ); 850 $hh = ($edit) ? mysql2date( 'H', $post_date ) : gmdate( 'H', $time_adj );852 $hh = ($edit) ? mysql2date( $hour_format, $post_date ) : gmdate( $hour_format, $time_adj ); 851 853 $mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj ); 852 854 $ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj ); 853 855 856 if( '12_hour' == $time_format ) { 857 $meridiem = ($edit) ? date( 'a', strtotime($post_date) ) : date( 'a' ); 858 $locale_meridiem = ($edit) ? $wp_locale->get_meridiem( date( 'A', strtotime($post_date) ) ) : $wp_locale->get_meridiem( date( 'A' ) ); 859 $locale_am = $wp_locale->get_meridiem( 'AM' ); 860 $locale_pm = $wp_locale->get_meridiem( 'PM' ); 861 } 854 862 $month = "<select id=\"mm\" name=\"mm\"$tab_index_attribute>\n"; 855 863 for ( $i = 1; $i < 13; $i = $i +1 ) { 856 864 $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"'; … … 864 872 $year = '<input type="text" id="aa" name="aa" value="' . $aa . '" size="4" maxlength="5"' . $tab_index_attribute . ' autocomplete="off" />'; 865 873 $hour = '<input type="text" id="hh" name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />'; 866 874 $minute = '<input type="text" id="mn" name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />'; 875 876 if( '12_hour' == $time_format ) { 877 $am_selected = $meridiem == 'am' ? 'selected="selected"' : ''; 878 $pm_selected = $meridiem == 'pm' ? 'selected="selected"' : ''; 879 880 $meridiem_drop_down = '<select name="meridiem" id="meridiem"' . $tab_index_attribute . '>' . PHP_EOL; 881 $meridiem_drop_down .= ' <option value="am" ' . $am_selected . '>' . $locale_am . '</option>' . PHP_EOL; 882 $meridiem_drop_down .= ' <option value="pm" ' . $pm_selected . '>' . $locale_pm . '</option>' . PHP_EOL; 883 $meridiem_drop_down .= '</selected>' . PHP_EOL; 884 } 885 867 886 printf(_c('%1$s%2$s, %3$s <br />@ %4$s : %5$s|1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input'), $month, $day, $year, $hour, $minute); 887 888 if ( '12_hour' == $time_format ) 889 echo $meridiem_drop_down; 890 868 891 echo "\n\n"; 869 892 foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) 870 893 echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n"; 894 895 if( '12_hour' == $time_format ) 896 echo '<input type="hidden" id="hidden_meridiem" name="hidden_meridiem" value="' . $meridiem . '" />'; 897 871 898 ?> 872 899 873 900 <input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" /> 901 <input type="hidden" id="time_format" name="time_format" value="<?php echo $time_format; ?>" /> 874 902 <?php 875 903 } 876 904 -
wp-admin/includes/user.php
old new 80 80 else 81 81 $user->admin_color = 'fresh'; 82 82 83 if ( !update ) 84 $user->time_format = '24_hour'; // Default to 24 hour time for new users. 85 else if ( isset( $_POST['time_format'] ) ) 86 $user->time_format = $_POST['time_format']; 87 else 88 $user->time_format = '24_hour'; 89 83 90 $errors = new WP_Error(); 84 91 85 92 /* checking that username has been typed */ -
wp-admin/user-edit.php
old new 161 161 </tr> 162 162 <?php endif; ?> 163 163 <tr> 164 <th scope="row"><?php _e('Editor Time Format')?></th> 165 <td> 166 <?php 167 $current_time_format = get_user_option('time_format', $user_id); 168 if ( !empty($current_time_format) && $current_time_format != '24_hour' && $current_time_format != '12_hour' ) 169 $current_time_format = '24_hour'; 170 ?> 171 <label for="time_format_12"><input name="time_format" id="time_format_12" type="radio" value="12_hour" <?php checked('12_hour', $current_time_format);?> />12-hour <i>2:35pm</i></label><br /> 172 <label for="time_format_24"><input name="time_format" id="time_format_24" type="radio" value="24_hour" <?php checked('24_hour', $current_time_format);?> />24-hour <i>14:35</i></label><br /> 173 </td> 174 </tr> 175 <tr> 164 176 <th scope="row"><?php _e('Admin Color Scheme')?></th> 165 177 <td> 166 178 <?php -
wp-includes/registration.php
old new 91 91 * 'jabber' - User's Jabber account. 92 92 * 'aim' - User's AOL IM account. 93 93 * 'yim' - User's Yahoo IM account. 94 * 'time_format' - A string used to set the user's chosen time format for the editor (12_hour or 24_hour) 94 95 * 95 96 * @since 2.0.0 96 97 * @uses $wpdb WordPress database layer. … … 157 158 if ( empty($admin_color) ) 158 159 $admin_color = 'fresh'; 159 160 $admin_color = preg_replace('|[^a-z0-9 _.\-@]|i', '', $admin_color); 160 161 162 if ( empty($time_format) ) { 163 $time_format = '24_hour'; 164 } else { 165 if ( $time_format != '12_hour' && $time_format != '24_hour' ) { 166 $time_format = '24_hour'; 167 } 168 } 169 161 170 if ( empty($user_registered) ) 162 171 $user_registered = gmdate('Y-m-d H:i:s'); 163 172 … … 181 190 update_usermeta( $user_id, 'yim', $yim ); 182 191 update_usermeta( $user_id, 'rich_editing', $rich_editing); 183 192 update_usermeta( $user_id, 'admin_color', $admin_color); 193 update_usermeta( $user_id, 'time_format', $time_format); 184 194 185 195 if ( $update && isset($role) ) { 186 196 $user = new WP_User($user_id);
