bugphpGroupWare - Bugs: bug #8315, Function convertDate in...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #8315: Function convertDate in class.datetime.inc.php does not work with the d-M-Y format that can selected in Preferences

Submitter:  Alan Oshry <scibe>
Submitted:  Fri 26 Mar 2004 08:43:50 PM UTC
   
 
Category:  API - phpGroupware API Item Group:  0.9.16.000 release
Severity:  3 - Normal Priority:  7 - High
Status:  Fixed Privacy:  Public
Assigned to:  skwashd Open/Closed:  Closed
Component Version:  SVN Operating System:  MS Windows
Reproducibility:  Every Time Planned Release:  None
Fixed Release: 

Jump to the original submission

Wed 31 Mar 2004 10:50:06 PM UTC, comment #7: 

Thanks skwashd!, this fixed the problem.

Alan Oshry <scibe>
Tue 30 Mar 2004 06:28:44 AM UTC, comment #6: 

I am about to upload a patch, scibe if you can test it, then I will commit it.

Cheers

Dave Hall <skwashd>
Group administrator
Sun 28 Mar 2004 08:17:35 PM UTC, comment #5: 

I had this isssue in another app.  I know a fix for it.  I will look into fixing it.

Dave Hall <skwashd>
Group administrator
Sat 27 Mar 2004 02:20:23 AM UTC, comment #4: 

The month name is not the issue, the code assembles the new date format by using the key, not the value. What makes it break is if any of the keys do not match the output keys. A developer using this function would need to know the format coming in, to prepare a proper output format that will work correctly. Since d-M-Y is the only dateformat preference that is unlike the others with the naming of the keys, it makes it difficult to know in advance to look for a d,m,Y combination, or a d,M,Y combination without editing the function itself to handle either one.

Anonymous
Sat 27 Mar 2004 01:47:04 AM UTC, comment #3: 

The month name is not the issue, the code assembles the new date format by using the key, not the value. What makes it break is if any of the keys do not match the output keys. A developer using this function would need to know the format coming in, to prepare a proper output format that will work correctly. Since d-M-Y is the only dateformat preference that is unlike the others with the naming of the keys, it makes it difficult to know in advance to look for a d,m,Y combination, or a d,M,Y combination without editing the function itself to handle either one.

Anonymous
Fri 26 Mar 2004 10:35:44 PM UTC, comment #2: 

Assuming that the month name is language dependend this is not trivial. Best solution would be to parse the given date into a timestamp and then return the new string by converting the timestamp (with strftime() for example).
The problem is still language depending parsing of the incoming string (strtotime() will NOT work here because it can not handle other formats/lnguages).

Kai Hofmann <powerstat>
Fri 26 Mar 2004 08:53:15 PM UTC, comment #1: 

This might be something for Powerstat to fix ...


Dr. Christian Böttger <cboettger>
Fri 26 Mar 2004 08:43:50 PM UTC, original submission:  

The function works like this, and returns the new formatted date:

convertDate($date, $dateFormat, $newFormat)

The function does this by finding the seperator used to seperate month, day, and year. Then builds an array of the month day values, and maps each value to the d/m/y format of the date passed.

For Example: Array ( [d] => 26 [m] => 03 [Y] => 2005 )

Then it finds the seperator of the format that you want the date to output the date to. Then builds an array of the month/day/year new format

And ultimately builds the new formmated date by starting from the order of the desired format, and matching the first value key with the old formmated value key.

An Example of what would make it not work:

convertDate('30-Mar-2004', 'd-M-Y', 'm-d-Y')

The passed date, turns into this:
For Example: Array ( [d] => 30 [M] => Mar [Y] => 2004 )

Notice how month is formmated as 'M' in the old format, and 'm' in the new format. At the end of the function when its building the end array that puts the old formmated date into the new formmated date, it looks for the 'm', but it cant find it, and returns a blank.

So the outcome will be: /30/2004

d-M-Y is the only dateformat Preference that is different than the rest because it has the 'M' instead of 'm'.

I am not sure what the best way to fix this is, but thought I would explain what is happening.

- scibe

Alan Oshry <scibe>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #1160:  class.datetime_fix.diff added by skwashd (1KiB - text/x-patch - fix typo in patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

 

Follow 9 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2004-05-01 skwashd StatusWorks For Me Fixed
    Open/ClosedOpen Closed
2004-03-30 skwashd Attached File- Added class.datetime_fix.diff, #1142
2004-03-30 skwashd Attached File#1141 Removed
2004-03-30 skwashd StatusNone Works For Me
    Attached File- Added class.datetime_fix.diff, #1141
2004-03-26 cboettger Priority5 - Normal 7 - High
    Assigned toNone skwashd
    Carbon-Copy- Added khofmann --AT-- probusiness --DOT-- de

Back to the top

Powered by Savane 3.13-d3ae.
Corresponding source code