Forums / Developer / "date" attribute limited 1970

"date" attribute limited 1970

Author Message

Santi Castells

Friday 19 October 2007 4:55:48 am

For one of our projects we have created a form which includes the "date" attribute in order to verify the date of birth of the user. However, we have realised that the "date" attribute is limited from the year 1970 and later. We need to introduce a new user who is born before that date (1964) but it reports an error "invalid date" and it doesn't save the info introduced in the form.

Manually we have changed the kernel of ez. first we have found the files which were controlling the "date" attribute (the following ones)...

kernel/classes/datatypes/ezdatetime/ezdatetimetype.php
kernel/classes/datatypes/ezdate/ezdatetype.php
lib/ezutils/classes/ezdatetimevalidator.php

Then we have changed the 1970 into an earlier date (1950).

The question is if this change will be affecting to the normal performance of eZ.

André R.

Friday 19 October 2007 5:08:27 am

This is a limitation in the date handling in php, it should be fixed in php 5, so it should in theory work on eZ Publish 4.0 (but I havn't personally tested this yet).

Alternative is to use the birthday-datatype:
http://ez.no/developer/contribs/datatypes/birthday_datatype

Most uptodate version is here:
http://svn.ez.no/svn/extensions/birthday_datatype/

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Santi Castells

Friday 19 October 2007 5:27:06 am

Thanks for your help.

Do you know if the manual change i have made on the kernel will be affecting negatively to the performance of ez? the thing is that the templates are already done with the "date" attribute and i would have to change quite a many if i wanna change the attribute type.

André R.

Friday 19 October 2007 5:43:02 am

Probably not.
But have you tested saving dates prior to 1970 after the kernel hack?
If so, what php version are you on?

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Santi Castells

Friday 19 October 2007 5:52:15 am

I changed it already and the specifically form works well, but don't know about general perfomance.
My php version is 4.4.7.

Thanks

Laurent BOURREL

Friday 19 October 2007 6:04:13 am

Hi,

I think it would be better to use a custom datatype than to modify the kernel...

For example :
http://ez.no/developer/contribs/datatypes/birthday_datatype

UPDATE : Oups, didn't see that the contrib was already posted, sorry guys :)