Skip to:
Content

bbPress.org

Changeset 1160


Ignore:
Timestamp:
02/29/2008 03:48:44 AM (18 years ago)
Author:
sambauers
Message:

Custom datetime and date formats in options. Props livibetter. Fixes #695

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/bb-admin/admin-functions.php

    r1107 r1160  
    209209        $r .= "\t\t<td><a href='mailto:$email'>$email</a></td>\n";
    210210    }
    211     $r .= "\t\t<td>$user->user_registered</td>\n";
     211    $r .= "\t\t<td>" . date( 'Y-m-d H:i:s', bb_offset_time( bb_gmtstrtotime( $user->user_registered ) ) ) . "</td>\n";
    212212    $actions = '';
    213213    if ( bb_current_user_can( 'edit_user', $user_id ) )
  • trunk/bb-admin/options-general.php

    r1058 r1160  
    104104            <p><?php _e('Example: -7 for Pacific Daylight Time.'); ?></p>
    105105        </div>
     106        <label for="datetime_format">
     107            <?php _e('Date and time format:') ?>
     108        </label>
     109        <div>
     110            <input class="text" name="datetime_format" id="datetime_format" value="<?php echo(attribute_escape(bb_get_datetime_formatstring_i18n())); ?>" />
     111            <p><?php printf(__('Output: <strong>%s</strong>'), bb_datetime_format_i18n( bb_current_time() )); ?></p>
     112        </div>
     113        <label for="date_format">
     114            <?php _e('Date format:') ?>
     115        </label>
     116        <div>
     117            <input class="text" name="date_format" id="date_format" value="<?php echo(attribute_escape(bb_get_datetime_formatstring_i18n('date'))); ?>" />
     118            <p><?php printf(__('Output: <strong>%s</strong>'), bb_datetime_format_i18n( bb_current_time(), 'date' )); ?></p>
     119            <p><?php _e('Click "Update options" to update sample output.') ?></p>
     120            <p><?php _e('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>.'); ?></p>
     121        </div>
    106122    </fieldset>
    107123    <fieldset>
  • trunk/bb-includes/locale.php

    r831 r1160  
    1212
    1313    var $meridiem;
     14    var $number_format;
     15    var $datetime_formatstring;
    1416
    1517    var $text_direction = '';
     
    100102        $this->number_format['thousands_sep'] = ('number_format_thousands_sep' == $trans) ? ',' : $trans;
    101103       
     104        // Date/Time formatting
     105       
     106        $this->datetime_formatstring['datetime'] = __('F j, Y - h:i A');
     107        $this->datetime_formatstring['date'] = __('F j, Y');
     108        $this->datetime_formatstring['time'] = __('h:i A');
     109       
    102110        $this->_load_locale_data();
    103111    }
     
    142150    function get_meridiem($meridiem) {
    143151        return $this->meridiem[$meridiem];
     152    }
     153
     154    function get_datetime_formatstring($type = 'datetime') {
     155        return $this->datetime_formatstring[$type];
    144156    }
    145157
     
    183195}
    184196
     197function bb_get_datetime_formatstring_i18n( $type = 'datetime' ) {
     198    $formatstring = bb_get_option( $type . '_format' );
     199    if ( empty($formatstring) ) {
     200        global $bb_locale;
     201        $formatstring = $bb_locale->get_datetime_formatstring( $type );
     202    }
     203    return $formatstring;
     204}
     205
     206function bb_datetime_format_i18n( $unixtimestamp, $type = 'datetime', $formatstring = '' ) {
     207    if ( empty($formatstring) ) {
     208        $formatstring = bb_get_datetime_formatstring_i18n( $type );
     209    }
     210    return bb_gmdate_i18n( $formatstring, bb_offset_time( $unixtimestamp ) );
     211}
     212
    185213function bb_number_format_i18n($number, $decimals = null) {
    186214    global $bb_locale;
  • trunk/bb-includes/template-functions.php

    r1156 r1160  
    14201420    echo "<dl id='userinfo'>\n";
    14211421    echo "\t<dt>" . __('Member Since') . "</dt>\n";
    1422     echo "\t<dd>" . bb_gmdate_i18n(__('F j, Y'), $reg_time) . ' (' . bb_since($reg_time) . ")</dd>\n";
     1422    echo "\t<dd>" . bb_datetime_format_i18n($reg_time, 'date') . ' (' . bb_since($reg_time) . ")</dd>\n";
    14231423    if ( is_array( $profile_info_keys ) ) {
    14241424        foreach ( $profile_info_keys as $key => $label ) {
  • trunk/bb-templates/kakumei/search.php

    r909 r1160  
    1414<li><h4><a href="<?php post_link(); ?>"><?php topic_title($bb_post->topic_id); ?></a></h4>
    1515<p><?php echo bb_show_context($q, $bb_post->post_text); ?></p>
    16 <p><small><?php _e('Posted') ?> <?php bb_post_time( __('F j, Y, h:i A') ); ?></small></p>
     16<p><small><?php _e('Posted') ?> <?php echo bb_datetime_format_i18n( bb_get_post_time( array( 'format' => 'timestamp' ) ) ); ?></small></p>
    1717</li>
    1818<?php endforeach; ?>
     
    2626<li><h4><a href="<?php post_link(); ?>"><?php topic_title($bb_post->topic_id); ?></a></h4>
    2727<p><?php echo bb_show_context($q, $bb_post->post_text); ?></p>
    28 <p><small><?php _e('Posted') ?> <?php bb_post_time( __('F j, Y, h:i A') ); ?></small></p>
     28<p><small><?php _e('Posted') ?> <?php echo bb_datetime_format_i18n( bb_get_post_time( array( 'format' => 'timestamp' ) ) ); ?></small></p>
    2929</li>
    3030<?php endforeach; ?>
Note: See TracChangeset for help on using the changeset viewer.