french format for dates

A place for users and developers of the Xataface to discuss and receive support.

Postby cbovio » Mon Mar 05, 2007 1:41 am

i'm testing dataface, great job !

my first problem is date format : how can i have format dd/mm/YYYY in lists, views and editions with calendar assistant ?

thanks,
cbovio
 
Posts: 25
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Mon Mar 05, 2007 12:30 pm

You can override the display of any field using delegate classes. E.g. if you have a column named "start_date" that is a datetime field. You can override how it is displayed with a function named start_date__display(). E.g.

Code: Select all
function start_date__display(&$record){
    return date('d/m/Y', strtotime($record->strval('start_date')));
}
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby chus_leon » Fri May 18, 2007 10:16 am

It's right but if you define one date field that could be null (like any date of end task), it shows 01-01-1970 instead of an empty field.

Is it possible to create a conditional function?

Thanks for the answer and also for the software. It's nice
chus_leon
 
Posts: 12
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Fri May 18, 2007 10:53 am

Hi,


How about this:
function mydate($format, $time=null){
ÊÊÊÊ if ( $time === 0 ) return '';Ê // return an empty string if time is 0
ÊÊÊÊ return date($format, $time);
}
Then your delegate class could use this instead of the date function:
function start_date__display(&$record){
return mydate('d/m/Y', strtotime($record->strval('start_date')));
}
I haven't tested it, but this should work.
Best regards
Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby chus_leon » Mon May 21, 2007 1:31 am

Sorry, it returns this error

Fatal error: Call to undefined function mydate() in K:\PortableApps\xampp\htdocs\soporte\tables\incidencia\incidencia.php on line 10

on line 10 I have

function fechasoluc__display(&$record){
return mydate('d-m-Y', strtotime($record->strval('fechasoluc')));
}

the function mydate is now defined on ApplicationDelegate.php. I tried also on my incidencias.php and returns the same error


Regards

Jesus
chus_leon
 
Posts: 12
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Mon May 21, 2007 6:17 am

If you define the function mydate(), make sure that it is outside all of your class definitions.

e.g.
class conf_ApplicationDelegate {
...
ÊÊÊ function mydate(){
ÊÊÊÊÊÊÊ ...
ÊÊÊ }
}

IS WRONG!
class conf_ApplicationDelegate {
...
}
function mydate(){
...
}
is CORRECT
=Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby chus_leon » Mon May 21, 2007 7:38 am

That's right. thanks again

Jesus
chus_leon
 
Posts: 12
Joined: Wed Dec 31, 1969 5:00 pm

Postby chus_leon » Sat Jun 09, 2007 1:08 am

Hi, another solution for the null dates is:

function datefield__display(&$record){
if ($record->val('datefield') == NULL) {
return '';
}else{
return date('d-m-Y', strtotime($record->strval('datefield')));
}
}



Regards
chus_leon
 
Posts: 12
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 22 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved