Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE development » Framework » Convert date ccyy-mm-dd to dd.mm.ccyy
Convert date ccyy-mm-dd to dd.mm.ccyy [message #5613] Wed, 08 June 2016 05:18 Go to next message
htManager is currently offline  htManager
Messages: 439
Registered: May 2014
Senior Member
If I print a pdf report I make changes in $fieldarray as mentioned in post sreen/report - concat fields in function _cm_post_fetchRow ($fieldarray). The date in $fieldarray['training_datum'] is shown in format ccyy-mm-dd. With the following code I want to change this but:

$css_array[0] = 'ddmmccyy';
$fieldarray['training_datum'] = $this->formatData($fieldarray['training_datum'], $css_array);

Is this the right way?

Re: Convert date ccyy-mm-dd to dd.mm.ccyy [message #5616 is a reply to message #5613] Wed, 08 June 2016 09:35 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
No. The $css_array argument allows for additional CSS classes to be defined for a field. This allows changes to the size, font and colour of the field but does NOT alter the contents of the field.

I suggest you take a look at FAQ13 and $GLOBALS['date_format']


Re: Convert date ccyy-mm-dd to dd.mm.ccyy [message #5618 is a reply to message #5616] Wed, 08 June 2016 10:16 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 439
Registered: May 2014
Senior Member
In the config.inc the $GLOBALS['date_format'] is set to 'dmy'. The language input-/output date format is set to 'dd.mm.yyyy'. Even in _cm_post_fetchRow the $GLOBALS['date_format'] is 'dmy'. Can it be that the formatting to 'dmy' will be done in a later step/function?
Re: Convert date ccyy-mm-dd to dd.mm.ccyy [message #5620 is a reply to message #5618] Thu, 09 June 2016 05:05 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
If you look at the formatData() method inside std.table.class.inc you will see that it can only format date fields if those fields have entries in the $fieldspec array which identifies them as having a type of 'date' or 'datetime'. If your output contains a field which does not have an entry in the $fieldspec array then it cannot be formatted and will be output as-is. You can fix this by manually updating the $fieldspec array in the _cm_changeConfig() method.

Re: Convert date ccyy-mm-dd to dd.mm.ccyy [message #5621 is a reply to message #5620] Thu, 09 June 2016 11:26 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 439
Registered: May 2014
Senior Member
I checked the type in _cm_change_config(). The fieldspec is 'date'.

What is the correct code in _cm_post_fetchRow() to call formatDate() in std.table.inc?

Is it: $fieldarray['training_datum'] = $this->formatData($fieldarray['training_datum']);

Does the formatDate() method automatically recognize the user settings in config.inc or in Menu System/languages? Or do I have to tell the formatDate() the output formatting?
Re: Convert date ccyy-mm-dd to dd.mm.ccyy [message #5622 is a reply to message #5621] Fri, 10 June 2016 04:46 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
You need to step through with your debugger to see what is happening when the formatData() method inside std.table.class.inc is called. You will see where it formats dates using $_SESSION['date_format_output'] which is set when passing through the logon screen.

Re: Convert date ccyy-mm-dd to dd.mm.ccyy [message #5623 is a reply to message #5622] Fri, 10 June 2016 10:38 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 439
Registered: May 2014
Senior Member
As far as I can see is the date formatted correctly until $fieldarray comes to std.pdf.class.inc.PDF->outputPDF_DetailView() line 1692 and std.pdf.class.inc.PDF->DetailView() line 283. In $fieldarray_formatted you can see the internal date format again.
Re: Convert date ccyy-mm-dd to dd.mm.ccyy [message #5624 is a reply to message #5623] Sat, 11 June 2016 05:22 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
In my prototype XAMPLE application, which is available in the online demo, I go to PROTO->Example->Person, select an entry and press the 'Output to PDF (D)' button and this runs through the code which you say is at fault. Line 279 contains the call to $dbobject->formatData(fieldarray). Before the call the value of START_DATE is in the format 'ccyy-mm-dd' and afterwards it is 'dd Mmm ccyy'. It appears in the PDF output as 'dd Mmm ccyy' so I can see nothing wrong.

Re: Convert date ccyy-mm-dd to dd.mm.ccyy [message #5626 is a reply to message #5624] Tue, 14 June 2016 03:58 Go to previous messageGo to next message
htManager is currently offline  htManager
Messages: 439
Registered: May 2014
Senior Member
You are right. There is no fault. If I output %%date_field in report.inc, everything is fine.

I get this problem, if I calculate an additional $fieldarray entry in _cm_post_fetchRow($fieldarray) in my class file with the following code:

$fieldarray['datum_output'] = 'Trainingsplan: ' . $fieldarray['training_datum'];

In this case the report shows: Trainingsplan: 2016-07-09

How can I get the formatted date at this point? Or do I have the possibility to calculate the $fieldarray entry at a later stage?
Re: Convert date ccyy-mm-dd to dd.mm.ccyy [message #5627 is a reply to message #5626] Tue, 14 June 2016 04:23 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
If you have created a new field in $fieldarray which does not have an entry in $this->fieldspec then the framework does not know what type it is, therefore cannot format it. You can correct this by adding an entry to $this->fieldspec in the _cm_changeConfig() method.

However, if the field is a concatenation of a string and a date then it cannot be formatted by the framework as it is a mixture of types. In this case you will have to format the date yourself before you append it to the string using the getExternalDate function.


Re: Convert date ccyy-mm-dd to dd.mm.ccyy [message #5629 is a reply to message #5627] Tue, 14 June 2016 05:46 Go to previous message
htManager is currently offline  htManager
Messages: 439
Registered: May 2014
Senior Member
Thank you very much. This is what I wanted. Works fine now.
Previous Topic: Screen/Report - calculated/concat fields
Next Topic: PopUp - Foreign Field/$selectarray (Info)
Goto Forum:
  


Current Time: Tue Dec 03 12:14:49 EST 2024

Total time taken to generate the page: 0.01646 seconds