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

Submitted by:  Alan Oshry <scibe>
Submitted on:  Fri 26 Mar 2004 08:43:50 PM UTC  
 
Item Group: 0.9.16.000 releaseCategory: API - phpGroupware API
Severity: 3 - NormalPriority: 7 - High
Status: FixedPrivacy: Public
Assigned to: Dave Hall <skwashd>Open/Closed: Closed
Component Version: SVNOperating System: MS Windows
Reproducibility: Every TimePlanned Release: None
Fixed Release: 

(Jump to the original submission 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>
Project AdministratorIn charge of this item.
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>
Project AdministratorIn charge of this item.
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>

 

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

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 9 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Sat 01 May 2004 09:32:44 AM UTCskwashdStatusWorks For Me=>Fixed
  Open/ClosedOpen=>Closed
Tue 30 Mar 2004 06:34:57 AM UTCskwashdAttached File-=>Added class.datetime_fix.diff, #1142
Tue 30 Mar 2004 06:34:49 AM UTCskwashdAttached File#1141=>Removed
Tue 30 Mar 2004 06:32:34 AM UTCskwashdStatusNone=>Works For Me
  Attached File-=>Added class.datetime_fix.diff, #1141
Fri 26 Mar 2004 08:53:15 PM UTCcboettgerPriority5 - Normal=>7 - High
  Assigned toNone=>skwashd
  Carbon-Copy-=>Added khofmann --AT-- probusiness --DOT-- de

Back to the top


Powered by Savane 3.1-cleanup1