CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Time Data Type

Print topic Send  topic

Author Message
Scott Elliott
Posted: 10/16/2002, 1:25 PM

Anyone know of a work around for a Time Data type?

I'm using CCS 1.0.7, PHP w/ Templates, MySQL.

Issue: I have a label as part of a grid that I want to display the hh:nn AM/PM format. There is no Time data type to use, so I assumed I could use the Date data type and set the DBFormat to HH:nn:ss (I actually typed this in as this was not a choice from the drop down list.) With this setup, nothing displays. If I change the data type to Text, I will get the actual HH:nn:ss, but I don't have the option to change to the hh:nn AM/PM format. BTW, my database datatype for the field in question is TIME.

Any suggestions?

Scott
Bryan Priem
Posted: 10/17/2002, 10:00 AM

I am having the same problem with the same configuration (1.0.7, php w/ templates, mysql).
Scott Elliott
Posted: 10/18/2002, 10:15 AM

I have received a response from Yes software, here's their suggestion (which works!):

"to display/update time values some modification are necessary in the CCParseDate() function. It is the problem with PHPpattern I emailed you modified function. Please replace current CCParseDate() function body with the emailed one. Note, that you should do it with all PHP projects you need to wok with time type feidls.
Then just enter HH:nn:ss into time field DBFormat property and type in desired format in the Format property."

Here's the code to use in place of old CCParseDate() (CCParseDate() is in the Common.php file):

//--------------------------
// Begin Updated CCParseDate
//--------------------------
function CCParseDate($ParsingDate, $FormatMask)
{
global $ShortMonths;
global $Months;

if(is_array($FormatMask) && strlen($ParsingDate))
{
$DateArray = array(0, "00", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
$RegExp = CCGetDateRegExp($FormatMask);
$IsValid = preg_match($RegExp[0], $ParsingDate, $matches);
for($i = 1; $i < sizeof($matches); $i++)
$DateArray[$RegExp[$i]] = $matches[$i];

if($DateArray[ccsMonth] == 0 && ($DateArray[ccsFullMonth] != 0 || $DateArray[ccsShortMonth] != 0))
{
if($DateArray[ccsFullMonth] != 0)
$DateArray[ccsMonth] = CCGetIndex($Months, $DateArray[ccsFullMonth], true) + 1;
else if($DateArray[ccsShortMonth] != 0)
$DateArray[ccsMonth] = CCGetIndex($ShortMonths, $DateArray[ccsShortMonth], true) + 1;
}

if($DateArray[ccsHour] < 12 && strtoupper($DateArray[ccsAmPm][0]) == "P")
$DateArray[ccsHour] += 12;

if($DateArray[ccsHour] == 12 && strtoupper($DateArray[ccsAmPm][0]) == "A")
$DateArray[ccsHour] = 0;

if(strlen($DateArray[ccsYear]) == 2)
if($DateArray[ccsYear] < 70)
$DateArray[ccsYear] = "20" . $DateArray[ccsYear];
else
$DateArray[ccsYear] = "19" . $DateArray[ccsYear];

if($DateArray[ccsYear] < 1971 && $DateArray[ccsYear] > 0)
$DateArray[ccsAppropriateYear] = $DateArray[ccsYear] + intval((2000 - $DateArray[ccsYear]) / 28) * 28;
else if($DateArray[ccsYear] > 2030)
$DateArray[ccsAppropriateYear] = $DateArray[ccsYear] - intval(($DateArray[ccsYear] - 2000) / 28) * 28;
else
$DateArray[ccsAppropriateYear] = $DateArray[ccsYear];

$DateArray[ccsTimestamp] = mktime ($DateArray[ccsHour], $DateArray[ccsMinute], $DateArray[ccsSecond], $DateArray[ccsMonth], $DateArray[ccsDay],
$DateArray[ccsAppropriateYear]);

if($DateArray[ccsTimestamp] < 0) $ParsingDate = "";
else $ParsingDate = $DateArray;

}

return $ParsingDate;
}
//--------------------------
// End Updated CCParseDate
//--------------------------


   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.