Navigation Menu

Skip to content

Commit

Permalink
Revert "Convert php date format string to moment.js format string"
Browse files Browse the repository at this point in the history
This reverts commit 0193226.
  • Loading branch information
cproensa authored and dregad committed Apr 16, 2017
1 parent 01294b7 commit 470adca
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 63 deletions.
2 changes: 1 addition & 1 deletion bug_actiongroup_page.php
Expand Up @@ -285,7 +285,7 @@

echo '<input type="text" id="due_date" name="due_date" class="datetimepicker input-sm" size="16" maxlength="16" ' .
'data-picker-locale="' . lang_get_current_datetime_locale() .
'" data-picker-format="' . convert_php_to_date_format( config_get( 'normal_date_format' ) ) . '"' .
'" data-picker-format="' . config_get( 'datetime_picker_format' ) . '"' .
'" value="' . $t_date_to_display . '" />';
echo '<i class="fa fa-calendar fa-xlg datetimepicker"></i>';
} else {
Expand Down
2 changes: 1 addition & 1 deletion bug_change_status_page.php
Expand Up @@ -243,7 +243,7 @@
<td>
<input type="text" id="due_date" name="due_date" class="datetimepicker input-sm" size="16" maxlength="16"
data-picker-locale="<?php lang_get_current_datetime_locale() ?>"
data-picker-format="<?php echo convert_php_to_date_format( config_get( 'normal_date_format' ) ) ?>"
data-picker-format="<?php echo config_get( 'datetime_picker_format' ) ?>"
<?php helper_get_tab_index() ?> value="<?php echo $t_date_to_display ?>" />
<i class="fa fa-calendar fa-xlg datetimepicker"></i>
</td>
Expand Down
2 changes: 1 addition & 1 deletion bug_report_page.php
Expand Up @@ -357,7 +357,7 @@ class="dropzone-form"
<td>
<?php echo '<input ' . helper_get_tab_index() . ' type="text" id="due_date" name="due_date" class="datetimepicker input-sm" ' .
'data-picker-locale="' . lang_get_current_datetime_locale() .
'" data-picker-format="' . convert_php_to_date_format( config_get( 'normal_date_format' ) ) . '" ' .
'" data-picker-format="' . config_get( 'datetime_picker_format' ) . '" ' .
'size="20" maxlength="16" value="' . $t_date_to_display . '" />' ?>
<i class="fa fa-calendar fa-xlg datetimepicker"></i>
</td>
Expand Down
3 changes: 1 addition & 2 deletions bug_update_page.php
Expand Up @@ -339,8 +339,7 @@
$t_date_to_display = date( config_get( 'normal_date_format' ), $t_bug->due_date );
}
echo '<input ' . helper_get_tab_index() . ' type="text" id="due_date" name="due_date" class="datetimepicker input-sm" size="16" ' .
'data-picker-locale="' . lang_get_current_datetime_locale() .
'" data-picker-format="' . convert_php_to_date_format( config_get( 'normal_date_format' ) ) .
'data-picker-locale="' . lang_get_current_datetime_locale() . '" data-picker-format="' . config_get( 'datetime_picker_format' ) . '" ' .
'" maxlength="16" value="' . $t_date_to_display . '" />';
echo '<i class="fa fa-calendar fa-xlg datetimepicker"></i>';
} else {
Expand Down
8 changes: 8 additions & 0 deletions config_defaults_inc.php
Expand Up @@ -1168,6 +1168,14 @@
*/
$g_datetime_picker_format = 'Y-MM-DD HH:mm';

/**
* Datetime picker widget format string for date only.
* For detailed instructions on date formatting
* @see http://momentjs.com/docs/#/displaying/format/
* @global string $g_datetime_picker_format
*/
$g_date_picker_format = 'Y-MM-DD';

##############################
# MantisBT TimeZone Settings #
##############################
Expand Down
58 changes: 5 additions & 53 deletions core/date_api.php
Expand Up @@ -245,64 +245,16 @@ function print_date_selection_set( $p_name, $p_format, $p_date = 0, $p_default_d
if( $p_default_disable == true ) {
$t_disable = ' readonly="readonly"';
}
$t_blank_line = '';
if( $p_allow_blank == true ) {
$t_blank_line = '<option value="0"></option>';
}

echo '<input ' . helper_get_tab_index() . ' type="text" name="' . $p_name . '_date" ' .
' class="datetimepicker ' . $p_input_css . '" ' . $t_disable .
' data-picker-locale="' . lang_get_current_datetime_locale() . '"' .
' data-picker-format="' . convert_php_to_date_format( $p_format ) . '"' .
' data-picker-format="' . config_get( 'date_picker_format' ) . '"' .
' size="12" maxlength="12" value="' . $t_date . '" />';
echo '<i class="fa fa-calendar fa-xlg datetimepicker"></i>';
}


/**
* Converts php date format string to moment.js date format.
* This function is used primarily with datetime picker widget.
* @param string $p_php_format Php date format string: http://php.net/manual/en/function.date.php
* @return string in moment.js format: http://momentjs.com/docs/#/displaying/format/
* @access public
*/
function convert_php_to_date_format( $p_php_format )
{
$t_replacements = array(
'd' => 'DD',
'D' => 'ddd',
'j' => 'D',
'l' => 'dddd',
'N' => 'E',
'S' => 'o',
'w' => 'e',
'z' => 'DDD',
'W' => 'W',
'F' => 'MMMM',
'm' => 'MM',
'M' => 'MMM',
'n' => 'M',
't' => '', // no equivalent
'L' => '', // no equivalent
'o' => 'YYYY',
'Y' => 'YYYY',
'y' => 'YY',
'a' => 'a',
'A' => 'A',
'B' => '', // no equivalent
'g' => 'h',
'G' => 'H',
'h' => 'hh',
'H' => 'HH',
'i' => 'mm',
's' => 'ss',
'u' => 'SSS',
'e' => 'zz', // deprecated since version 1.6.0 of moment.js
'I' => '', // no equivalent
'O' => '', // no equivalent
'P' => '', // no equivalent
'T' => '', // no equivalent
'Z' => '', // no equivalent
'c' => '', // no equivalent
'r' => '', // no equivalent
'U' => 'X',
);

return strtr( $p_php_format, $t_replacements );
}
8 changes: 4 additions & 4 deletions core/filter_form_api.php
Expand Up @@ -1287,7 +1287,7 @@ function print_filter_do_filter_by_date( $p_hide_checkbox = false, array $p_filt
echo '<input type="text" name="' . FILTER_PROPERTY_START_DATE_SUBMITTED . '" ' .
' class="datetimepicker input-xs" ' . $t_menu_readonly .
' data-picker-locale="' . lang_get_current_datetime_locale() . '"' .
' data-picker-format="' . convert_php_to_date_format( config_get( 'normal_date_format' ) ) . '"' .
' data-picker-format="' . config_get( 'date_picker_format' ) . '"' .
' size="12" maxlength="12" value="' . $p_filter[FILTER_PROPERTY_START_DATE_SUBMITTED] . '" />';
echo '<i class="fa fa-calendar fa-xlg datetimepicker"></i>';
?>
Expand All @@ -1303,7 +1303,7 @@ function print_filter_do_filter_by_date( $p_hide_checkbox = false, array $p_filt
echo '<input type="text" name="' . FILTER_PROPERTY_END_DATE_SUBMITTED . '" ' .
' class="datetimepicker input-xs" ' . $t_menu_readonly .
' data-picker-locale="' . lang_get_current_datetime_locale() . '"' .
' data-picker-format="' . convert_php_to_date_format( config_get( 'normal_date_format' ) ) . '"' .
' data-picker-format="' . config_get( 'date_picker_format' ) . '"' .
' size="12" maxlength="12" value="' . $p_filter[FILTER_PROPERTY_END_DATE_SUBMITTED] . '" />';
echo '<i class="fa fa-calendar fa-xlg datetimepicker"></i>';
?>
Expand Down Expand Up @@ -1380,7 +1380,7 @@ function print_filter_do_filter_by_last_updated_date( $p_hide_checkbox = false,
echo '<input type="text" name="' . FILTER_PROPERTY_LAST_UPDATED_START_DATE . '" ' .
' class="datetimepicker input-xs" ' . $t_menu_readonly .
' data-picker-locale="' . lang_get_current_datetime_locale() . '"' .
' data-picker-format="' . convert_php_to_date_format( config_get( 'normal_date_format' ) ) . '"' .
' data-picker-format="' . config_get( 'date_picker_format' ) . '"' .
' size="12" maxlength="12" value="' . $p_filter[FILTER_PROPERTY_LAST_UPDATED_START_DATE] . '" />';
echo '<i class="fa fa-calendar fa-xlg datetimepicker"></i>';
?>
Expand All @@ -1396,7 +1396,7 @@ function print_filter_do_filter_by_last_updated_date( $p_hide_checkbox = false,
echo '<input type="text" name="' . FILTER_PROPERTY_LAST_UPDATED_END_DATE . '" ' .
' class="datetimepicker input-xs" ' . $t_menu_readonly .
' data-picker-locale="' . lang_get_current_datetime_locale() . '"' .
' data-picker-format="' . convert_php_to_date_format( config_get( 'normal_date_format' ) ) . '"' .
' data-picker-format="' . config_get( 'date_picker_format' ) . '"' .
' size="12" maxlength="12" value="' . $p_filter[FILTER_PROPERTY_LAST_UPDATED_END_DATE] . '" />';
echo '<i class="fa fa-calendar fa-xlg datetimepicker"></i>';
?>
Expand Down
2 changes: 1 addition & 1 deletion manage_proj_ver_edit_page.php
Expand Up @@ -99,7 +99,7 @@
<td>
<input type="text" id="proj-version-date-order" name="date_order" class="datetimepicker input-sm"
data-picker-locale="<?php echo lang_get_current_datetime_locale() ?>"
data-picker-format="<?php echo convert_php_to_date_format( config_get( 'normal_date_format' ) ) ?>"
data-picker-format="<?php echo config_get( 'datetime_picker_format' ) ?>"
size="16" value="<?php echo (date_is_null( $t_version->date_order ) ? '' : string_attribute( date( config_get( 'normal_date_format' ), $t_version->date_order ) ) ) ?>" />
<i class="fa fa-calendar fa-xlg datetimepicker"></i>
</td>
Expand Down

0 comments on commit 470adca

Please sign in to comment.