Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update date_helper.php #1515

Closed
wants to merge 1 commit into from

Conversation

sugenganthos
Copy link
Contributor

Add validate date string or time string.
This should be in input filter i think. But still don't know how to integrate there

Add validate date string or time string.
This should be in input filter i think.  But still don't know how to integrate there
*/
function validate_date(string $dateString):bool
{
$dateArr = explode('-', $dateString);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no way to know that a date string will be separated by dashes. In the US, I know that's common, but strtotime requires forward slashes to know it's a UK time and know which position the month and the day are. I'm sure this applies to other parts of the world, also, but, the point is you can't guarantee, so you'll need to find another way to get the date.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we must have have another param to specify the date string format expected.
In Ci3, I use this : validate_date(string $dateString, string $dateFormat).
In france, the commonly format is dd/mm/yyyy.

Copy link
Contributor Author

@sugenganthos sugenganthos Nov 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These function is supposed to validate input from <input type="date"> and <input type="time"> elements. Not from user input.
html input on MDN says that date value always yyyy-mm-dd. That is what sent to the server. That is different from displayed date which is regards on locale setting.
Also on validate_time respectively.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's the intent, then it should be in a Validation rule, not the date helper. The date helper is for general usage, which this doesn't work for. However, this method already exists as a validation rule, so this appears to not be needed for what you intend.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validate_time method should be made a validation rule, as well.

@sugenganthos sugenganthos deleted the patch-4 branch November 23, 2018 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants