Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

DateTime form element weird DateInterval step!? #4960

Closed
TonyBogdanov opened this issue Aug 14, 2013 · 3 comments
Closed

DateTime form element weird DateInterval step!? #4960

TonyBogdanov opened this issue Aug 14, 2013 · 3 comments
Assignees
Milestone

Comments

@TonyBogdanov
Copy link

Can someone explain what is the reason behind setting the DateInterval step to a minute instead of a second or even a millisecond in https://github.com/zendframework/zf2/blob/master/library/Zend/Form/Element/DateTime.php#L172 ?

Better, can someone explain why the DateTime element should have a DateStep validator at all?

My problem here, is that with minimal setup, one can never submit a datetime value with seconds != 0, because the step is set to a minute. It just goes into an infinite validation loop.

@mauriciopiber
Copy link

Did you fix it?

kamioftea added a commit to kamioftea/zf2 that referenced this issue Jan 8, 2015
Start from lower bound valid date rather than base date when iterating
through valid date times
@kamioftea
Copy link
Contributor

The problem with the validation is not infinite, but the validator starts at the base date (which is 1/1/1970 if no min attribute is set) and increments by the step until it reaches or passes the submitted datetime which takes enough time that the script times out. I've created a pull request to help improve this here: [https://github.com//pull/7110]

To get round the step validation entirely you can set a step attribute of 'any' to prevent the DateStep validator being added.

The default step is 60 seconds for a datetime element WHATWG Spec (There is no datetime element in the W3C spec anymore but time also matches this W3C Time Spec. This suggests that the default should really by a DateStep with a DateInterval('PT60S').

There is an unfortunate side affect of changing the default date interval in that it will no longer be caught by the quicker check that only applies when there is a single interval unit with value 1, so will start to use the longer validation.

@Ocramius Ocramius added the bug label Jan 8, 2015
@Ocramius Ocramius added this to the 2.3.4 milestone Jan 8, 2015
@Ocramius Ocramius self-assigned this Jan 8, 2015
Ocramius pushed a commit that referenced this issue Jan 12, 2015
Start from lower bound valid date rather than base date when iterating
through valid date times
Ocramius added a commit that referenced this issue Jan 12, 2015
Ocramius added a commit that referenced this issue Jan 12, 2015
Ocramius added a commit that referenced this issue Jan 12, 2015
…on into private method, renaming variables for clarity
Ocramius added a commit that referenced this issue Jan 12, 2015
Ocramius added a commit that referenced this issue Jan 12, 2015
Ocramius added a commit that referenced this issue Jan 12, 2015
Ocramius added a commit that referenced this issue Jan 12, 2015
Ocramius added a commit that referenced this issue Jan 12, 2015
@Ocramius
Copy link
Member

Handled in #7110

gianarb pushed a commit to zendframework/zend-validator that referenced this issue May 15, 2015
Start from lower bound valid date rather than base date when iterating
through valid date times
gianarb pushed a commit to zendframework/zend-validator that referenced this issue May 15, 2015
gianarb pushed a commit to zendframework/zend-validator that referenced this issue May 15, 2015
gianarb pushed a commit to zendframework/zend-validator that referenced this issue May 15, 2015
…efactoring logic for interval max and min diff seconds into private methods
gianarb pushed a commit to zendframework/zend-validator that referenced this issue May 15, 2015
gianarb pushed a commit to zendframework/zend-validator that referenced this issue May 15, 2015
…efactoring `$minSteps` definition logic into own private method
gianarb pushed a commit to zendframework/zend-validator that referenced this issue May 15, 2015
…xtracting logic for `requiredStepIterations` computation into private method, renaming variables for clarity
gianarb pushed a commit to zendframework/zend-validator that referenced this issue May 15, 2015
…efactoring computation of minimum viable interval into a private method
gianarb pushed a commit to zendframework/zend-validator that referenced this issue May 15, 2015
…efactoring step iteration logic for better readability
gianarb pushed a commit to zendframework/zend-validator that referenced this issue May 15, 2015
…oving fallback iteration logic to own private method
gianarb pushed a commit to zendframework/zend-validator that referenced this issue May 15, 2015
gianarb pushed a commit to zendframework/zend-validator that referenced this issue May 15, 2015
…enaming variables and private methods for clarity, removing explicit use of `$minSteps`
gianarb pushed a commit to zendframework/zend-validator that referenced this issue May 15, 2015
…enaming private methods to not make them look like getters
gianarb pushed a commit to zendframework/zend-validator that referenced this issue May 15, 2015
gianarb pushed a commit to zendframework/zend-validator that referenced this issue May 15, 2015
gianarb pushed a commit to zendframework/zend-validator that referenced this issue May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants