View Issue Details

IDProjectCategoryView StatusLast Update
0008880mantisbtdb postgresqlpublic2014-05-16 15:02
Reportersmig1o Assigned Togiallu  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformLAPPOSLinuxOS Version2.6.18
Product Version1.1.1 
Fixed in Version1.1.2 
Summary0008880: Problem with date formatting in db_prepare_date function
Description

function
db_prepare_date( $p_yyyymmdd )
should format date into string:

YYYY-mm-dd

If argument will be in format yyyy-mm-dd, ie: 2008-02-18 after formatting you'll get: 2008-002-18.

Steps To Reproduce

Call function db_prepare_date ( '2008-02-18' )

Additional Information

The solution:
at the end of function:
// Format
$t_formatted = $t_a[0] . '-';
$t_formatted .= ($t_a[1] < 10 ? "0" . $t_a[1] : $t_a[1]) . '-';
$t_formatted .= ($t_a[2] < 10 ? "0" . $t_a[2] : $t_a[2]);

should be replaced with
// Format
$t_formatted = $t_a[0] . '-';
$t_formatted .= ($t_a[1] < 10 ? "0" . (integer)$t_a[1] : $t_a[1]) . '-';
$t_formatted .= ($t_a[2] < 10 ? "0" . (integer)$t_a[2] : $t_a[2]);

Tagspatch
Attached Files
db_prepare_date.diff (629 bytes)   
Index: core/database_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/database_api.php,v
retrieving revision 1.75
diff -u -r1.75 database_api.php
--- core/database_api.php	28 Oct 2007 01:06:36 -0000	1.75
+++ core/database_api.php	12 Feb 2008 10:16:02 -0000
@@ -613,9 +613,7 @@
 		}
 
 		// Format
-		$t_formatted = $t_a[0] . '-';
-		$t_formatted .= ($t_a[1] < 10 ? "0" . $t_a[1] : $t_a[1]) . '-';
-		$t_formatted .= ($t_a[2] < 10 ? "0" . $t_a[2] : $t_a[2]);
+		$t_formatted = sprintf('%04d-%02d-%02d', $t_a[0], $t_a[1], $t_a[2]);
 
 		return $t_formatted;
 	}
db_prepare_date.diff (629 bytes)   

Relationships

parent of 0008878 closedgiallu Copy Versions scrambles Timestamp 
has duplicate 0009044 closedgiallu copy Versions from root projects 
has duplicate 0009307 closedgiallu Copy Version from produce incorrect timestamp 
related to 0009651 closedjreese Version copy from parent project copies incorrect date 

Activities

ryandesign

ryandesign

2008-02-12 05:16

reporter   ~0017015

Actually this is all much simpler if we would just use sprintf(). Patch attached.

smig1o

smig1o

2008-02-13 03:24

reporter   ~0017035

Thanks for so quick reaction. Now let me test it ;)

smig1o

smig1o

2008-02-28 03:12

reporter   ~0017214

I think this issue should be closed then

ryandesign

ryandesign

2008-02-28 03:18

reporter   ~0017215

I think the patch should be checked in to CVS. Then the issue can be closed.

giallu

giallu

2008-03-05 19:35

reporter   ~0017263

Fixed in SVN revision 5089

grangeway

grangeway

2014-05-16 15:02

reporter   ~0040553

MantisBT currently supports Mysql and has support for other database engines.

The support for other databases is known to be problematic.

Having implemented the current database layer into Mantis 10 years ago, I'm currently working on replacing the current layer.

If you are interested in using Mantis with non-mysql databases - for example, Oracle, PGSQL or MSSQL, and would be willing to help out testing the new database layer, please drop me an email at paul@mantisforge.org

In the meantime, I'd advise running Mantis with Mysql Only to avoid issues.

Thanks
Paul

Related Changesets

MantisBT: master-1.1.x 5cf74fea

2008-03-05 19:34

giallu


Details Diff
Fix 8880: Problem with date formatting in db_prepare_date function

This should also fix 8878 and 8792

git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/branches/BRANCH_1_1_0@5089 <a class="text" href="/?p=mantisbt.git;a=object;h=f5dc347c">f5dc347c</a>-c33d-0410-90a0-b07cc1902cb9
Affected Issues
0008878, 0008880
mod - core/database_api.php Diff File