Relationship Graph
View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0034928 | mantisbt | bugtracker | public | 2024-11-01 09:23 | 2025-09-21 06:48 |
Reporter | filipesantos | Assigned To | dregad | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 2.27.0 | ||||
Target Version | 2.28.0 | Fixed in Version | 2.28.0 | ||
Summary | 0034928: Date conversion fails using a non-US date format in VersionUpdateCommand.php | ||||
Description | Hello everyone in the community. In my installation, I replaced the line $t_timestamp = strtotime( $t_timestamp ); by $t_timestamp = date_strtotime ( $t_timestamp ); and resolved it. | ||||
Steps To Reproduce | configure mantis to use non-US date format (DD/MM/YYYY HH:mm) | ||||
Tags | No tags attached. | ||||
Thanks for the report. I guess VersionUpdateCommand was forgotten in the fix for 0031836. I'll have a look. EDIT: actually VersionUpdateCommand was added in 0030415 (2.26.0), after 0031836 was fixed (2.25.6). |
|
Hello @filipesantos I have tried to reproduce the problem, but couldn't. As far as I can tell it is working as expected. Can you please confirm that you have configured $g_datetime_picker_format as appropriate to match $g_normal_date_format, as explained in the admin guide ? If not, please clarify the steps to reproduce, including your values for $g_datetime_picker_format and $g_normal_date_format, as well as the date(s) you entered and the actual error you got including stack trace (temporarily set |
|
Hello @dregad $g_short_date_format = 'd/m/Y'; With these settings representing the Brazilian date format, where first is the day, month and year; When creating a new version everything happens fine. I created a version at this moment, that is, its date is 03/11/2024 11:00, if I click on change the date is loaded correctly in Picker, but when saving it is inverted to 11/03/2024 11:00, in other words, he changed the day to the month. When analyzing the VersionUpdateCommand.php file, I noticed that when converting date to timestamp it still uses strtotime, which only accepts dates in the US standard. Sorry for my bad English. |
|
Thanks for the feedback, and don't worry about your English, it is perfectly fine. I was actually testing with my own local date format, which uses period As a workaround pending a fix in MantisBT code, you could use I believe your proposition to update VersionUpdateCommand is not appropriate, as it was decided not to allow custom date formats from REST API (see discussion in PR https://github.com/mantisbt/mantisbt/pull/1864#discussion_r1065202271, leading to removal of date_strtotime() from the related Commands in MantisBT master-2.25 f6c250af ) I think the change should go in manage_proj_ver_update.php, I'll analyze in more details later. |
|
@filipesantos it would be great if you could test the proposed fix and provide feedback, either here or on the GitHub pull request. |
|
Changing target version to 2.28.0 as the change is not so trivial anymore and could potentially introduce regressions. |
|
MantisBT: master c5fba7f4 2024-11-04 12:35 Details Diff |
Update Version date conversion with non-US format VersionAddCommand and VersionUpdateCommand now accept a Unix timestamp as payload for timestamp (date_order). manage_proj_ver_update.php calls date_strtotime() on the $f_timestamp parameter to build the VersionUpdateCommand payload. Fixes 0034928 |
Affected Issues 0034928 |
|
mod - core/commands/VersionAddCommand.php | Diff File | ||
mod - core/commands/VersionUpdateCommand.php | Diff File | ||
mod - manage_proj_ver_update.php | Diff File | ||
MantisBT: master b155dbfb 2025-02-26 18:43 Details Diff |
New API functions for date conversions As requested in PR review, it is no longer possible to provide timestamp (version date order) as an integer to REST API /projects/{{id}}/versions endpoints. It is worth noting that a Unix timestamp can technically still be given, using the `@{integer}` syntax, since that is a valid format for the DateTimeImmutable constructor. This could change in the future, if we decide to only allow ISO-8601 format. The datetime parsing and generation logic has been standardized in 2 new date API functions: - date_string_to_timestamp() - date_timestamp_to_iso8601() Use the new functions in: - date_strtotime() - ApiObjectFactory: methods datetime() and datetimeString(); add new dateStringToTimestamp() method. - VersionAddCommand - VersionUpdateCommand Fixes 0034928 |
Affected Issues 0034928 |
|
mod - api/soap/mc_api.php | Diff File | ||
mod - core/commands/VersionAddCommand.php | Diff File | ||
mod - core/commands/VersionUpdateCommand.php | Diff File | ||
mod - core/date_api.php | Diff File | ||
mod - manage_proj_ver_update.php | Diff File |