View Issue Details

IDProjectCategoryView StatusLast Update
0023701mantisbtlocalizationpublic2018-07-25 11:35
Reporterchadmiss Assigned To 
PrioritynormalSeveritymajorReproducibilityhave not tried
Status newResolutionopen 
Summary0023701: different or localized datetime formats delete due_date on updates
Description

the parameters

$g_normal_date_format;
and
$g_datetime_picker_format;

have to have the same display format (the definition spec is different for those parameters), otherwise the original due_date is not shown when updating a bug.

something like
$g_normal_date_format = 'd-m-Y H:i';
$g_datetime_picker_format = 'DD-MM-Y HH:mm';
will produce the same display-format and works fine

this configuration will result in an empty due_date field:
$g_normal_date_format = 'd-m-Y H:i';
$g_datetime_picker_format = 'DD-MMM-Y HH:mm';

also when using a date-format with localized names for the datetimepicker (for example german "10-Dez-2017", config from the second example) the sent value will not be translated to a timestamp in bug_update.php by strtotime()

TagsNo tags attached.
Attached Files

Relationships

related to 0023578 closeddregad Document need for consistency between "normal" and "datepicker" date formats 
has duplicate 0024514 closedatrol duedate broken 

Activities

Mr.Bricodage

Mr.Bricodage

2018-07-25 11:35

reporter   ~0060321

On 2.15.0, my config :
$g_short_date_format = 'd/m/Y';
$g_complete_date_format = 'd/m/Y H:i:s T';
$g_normal_date_format = 'd/m/Y H:i:s';
$g_datetime_picker_format = 'DD/MM/YYYY HH:mm:ss';

Consistency is compliant with warning provided in https://www.mantisbt.org/docs/master/en-US/Admin_Guide/html-desktop/#admin.config.date.

During version update, I can see that the saved date is wrong : define 06/08/2018 on screen, 08/06/2018 is saved. Month and day are switched.

My workaround to transform custom date format to default date format awaited by , in manage_proj_ver_update.php,

$defined_date = DateTime::createFromFormat( config_get( 'normal_date_format' ),$f_date_order ); # consistency between normal and datepicker is mandatory because we use normal_date_format to understand a date defined in GUI through datetime_picker_format
$t_version->date_order = $defined_date->format( 'Y-m-d H:i:s' ); # default normal_date_format in config_default_inc.php
workaround.diff (1,200 bytes)   
diff --git a/manage_proj_ver_update.php b/manage_proj_ver_update.php
index 538fc6697..294ada949 100644
--- a/manage_proj_ver_update.php
+++ b/manage_proj_ver_update.php
@@ -65,6 +65,7 @@ $f_description  = gpc_get_string( 'description' );
 $f_released     = gpc_get_bool( 'released' );
 $f_obsolete	= gpc_get_bool( 'obsolete' );
 
+
 access_ensure_project_level( config_get( 'manage_project_threshold' ), $t_version->project_id );
 
 if( is_blank( $f_new_version ) ) {
@@ -77,7 +78,8 @@ $t_version->version = $f_new_version;
 $t_version->description = $f_description;
 $t_version->released = $f_released ? VERSION_RELEASED : VERSION_FUTURE;
 $t_version->obsolete = $f_obsolete;
-$t_version->date_order = $f_date_order;
+$defined_date = DateTime::createFromFormat( config_get( 'normal_date_format' ),$f_date_order ); # consistency between normal and datepicker is mandatory because we use normal_date_format to understand a date defined in GUI through datetime_picker_format
+$t_version->date_order = $defined_date->format( 'Y-m-d H:i:s' ); # default normal_date_format in config_default_inc.php
 
 version_update( $t_version );
 event_signal( 'EVENT_MANAGE_VERSION_UPDATE', array( $t_version->id ) );
workaround.diff (1,200 bytes)