General Problem with ezdate before 1970?

Author Message

Norman Leutner

Monday 25 September 2006 1:12:09 am

I have a user attribute birthdate (ezdate).

If a user tries to register with a date before 01.01.1970 he gets a error:
"Date not valid"

This seems to be a general problem with the datatype in combination with the time function.

Does anybody have a workaround for me how to fix this?

Mit freundlichen Grüßen
Best regards

Norman Leutner

____________________________________________________________
eZ Publish Platinum Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh

Norman Leutner

Monday 25 September 2006 1:25:16 am

/ezp383/lib/ezutils/classes/ezdatetimevalidator.php

    function validateDate( $day, $month, $year )
    {
        $check = checkdate( $month, $day, $year );
        $datetime = mktime( 0, 0, 0, $month, $day, $year );
        if ( !$check or
             $year < 1970 or
             $datetime === false )
        {
            return EZ_INPUT_VALIDATOR_STATE_INVALID;
        }
        return EZ_INPUT_VALIDATOR_STATE_ACCEPTED;
    }

Mit freundlichen Grüßen
Best regards

Norman Leutner

____________________________________________________________
eZ Publish Platinum Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh

Norman Leutner

Monday 25 September 2006 1:35:26 am

Ok,
I think I'll need to split the birthdate into three servel integer fields.

Mit freundlichen Grüßen
Best regards

Norman Leutner

____________________________________________________________
eZ Publish Platinum Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh

Paul Forsyth

Monday 25 September 2006 1:36:18 am

its a general php problem. php 4 doesnt handle timestamps before 1970. have a google around for this.

if you want to hack the php you may be able to have negative timestamps and write some code to interpret this. if you look on the php.net/strtotime comments you'll find people with similar issues and workaround.

i believe php5 handles the negative timestamps more gracefully than php4...

paul

Xavier Dutoit

Monday 25 September 2006 1:54:32 am

Hi,

Have a look at the birthday datatype in the contrib:
http://ez.no/community/contribs/datatypes/birthday_datatype

Haven't tested with a recent ez version.

X+

http://www.sydesy.com

Paul Forsyth

Monday 25 September 2006 1:57:06 am

Good spot Xavier, I completely forgot about that extension.

I wrote my own the other day to do something similar :(

Paul

Norman Leutner

Monday 25 September 2006 2:20:05 am

Thanks for you help,
I installed the extension and added the GregorianToJD function.

Works fine.

Mit freundlichen Grüßen
Best regards

Norman Leutner

____________________________________________________________
eZ Publish Platinum Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh

Xavier Dutoit

Monday 25 September 2006 5:10:11 am

Hi,

I think that's a problem in general: that's hard to find extensions in the contrib and everyone re do the same things (see the countries ones), then ez develop something similar on its own.

I'd help if the contrib could be made more visible in the documentation...

X+

http://www.sydesy.com

Xavier Dutoit

Monday 25 September 2006 5:12:32 am

@Paul,

The other thing is that even if Guiness is good for you, it doesn't help for the memory ;)

X+

http://www.sydesy.com

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 15:55:24
Script start
Timing: Jan 18 2025 15:55:24
Module start 'layout'
Timing: Jan 18 2025 15:55:24
Module start 'content'
Timing: Jan 18 2025 15:55:25
Module end 'content'
Timing: Jan 18 2025 15:55:25
Script end

Main resources:

Total runtime0.7037 sec
Peak memory usage4,096.0000 KB
Database Queries77

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 588.0078152.6250
Module start 'layout' 0.00560.0025 740.632839.4453
Module start 'content' 0.00810.6941 780.0781646.9844
Module end 'content' 0.70230.0014 1,427.062520.1406
Script end 0.7036  1,447.2031 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00300.4243160.0002
Check MTime0.00130.1781160.0001
Mysql Total
Database connection0.00100.146410.0010
Mysqli_queries0.634290.1294770.0082
Looping result0.00060.0783750.0000
Template Total0.676496.120.3382
Template load0.00180.262320.0009
Template processing0.674595.854420.3373
Template load and register function0.00010.014510.0001
states
state_id_array0.00100.135910.0010
state_identifier_array0.00120.175120.0006
Override
Cache load0.00160.2329490.0000
Sytem overhead
Fetch class attribute can translate value0.00090.122130.0003
Fetch class attribute name0.00100.1457110.0001
XML
Image XML parsing0.00130.184930.0004
class_abstraction
Instantiating content class attribute0.00000.0049160.0000
General
dbfile0.00100.1403230.0000
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
9content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 34
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs