View Issue Details

This bug affects 1 person(s).
 8
IDProjectCategoryView StatusLast Update
09591Bug reportsSurvey takingpublic2015-06-20 12:16
Reportergabrieljenik Assigned Tomfaber  
PrioritynormalSeverityminor 
Status closedResolutionno change required 
Product Version2.05+ 
Summary09591: Sometimes date_max / date_min validations for date/time questions doesn't allow to use the maximum date expected
Description

When using date_max / date_min validations for date/time questions, validation doesn't allow to use as pinut the "max date" expected.

Question settings:
Date format: dd/mm/yyyy
max_date: date("Y-m-d")

Question attached.

TagsNo tags attached.
Attached Files
Bug heat8
Complete LimeSurvey version number (& build)150310
I will donate to the project if issue is resolvedNo
Browser
Database type & versionMySQL
Server OS (if known)Linux
Webserver software & version (if known)Apache
PHP Version5.5

Relationships

related to 09701 closedmfaber Setting max date in date question does not work like before 

Users monitoring this issue

mfaber

Activities

mfaber

mfaber

2015-03-27 20:30

reporter   ~31922

Last edited: 2015-03-27 21:24

It works using date("Y-m-d H:i") instead of date("Y-m-d").

The comparison fails at the moment because
[date from datepicker] =< date("Y-m-d")
i.e.
2015-03-27 00:00 =< 2015-03-27
is not true.

I also corrected a mistake in the wiki concerning date_max

gabrieljenik

gabrieljenik

2015-03-31 20:29

manager   ~31931

Added some code to enhance comparison and avoid errors like I got.

PR: https://github.com/LimeSurvey/LimeSurvey/pull/298
Commit: https://github.com/LimeSurvey/LimeSurvey/commit/4b7f15e4a1c6596c72a2cb69d67688d6ce748efe

gabrieljenik

gabrieljenik

2015-03-31 23:02

manager   ~31932

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&amp;id=15062

mfaber

mfaber

2015-03-31 23:02

reporter   ~31933

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&amp;id=15063

gabrieljenik

gabrieljenik

2015-03-31 23:22

manager   ~31934

PR for v2.06: https://github.com/LimeSurvey/LimeSurvey/pull/299
Commit: https://github.com/gabrieljenik/LimeSurvey/commit/2d6849a8ae267c4868bde63fd01561169c03bd94

mfaber

mfaber

2015-03-31 23:36

reporter   ~31935

Fix committed to 2.06 branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&amp;id=15065

c_schmitz

c_schmitz

2015-04-21 10:51

administrator   ~32025

The change breaks usage of certain EM conditions for min/max values.

For example it was previously possible to use

Maximum date: date('Y-m-d')+1

Now this condition does not validate properly.
This needs to be fixed urgently.

mfaber

mfaber

2015-04-21 13:13

reporter   ~32029

I do not know what LS produced with "date('Y-m-d')+1", but it is not a valid expression. Date() produces a string in the given format and "+1" likely adds a "1" to the string. A correct expression to allow for dates up to tomorrow would be: date("Y-m-d H:i", strtotime("now")+606024). But maybe there are other ways.

c_schmitz

c_schmitz

2015-04-21 14:10

administrator   ~32030

You are right - sorry, can be closed again.

gabrieljenik

gabrieljenik

2015-04-21 19:08

manager   ~32032

I am reopening this to make some comments about previous notes.

When adding a date question, date_min and date_max are attributes that are said to handle expressions, as << date('Y-m-d') + 1 >>.

As now, inside the code, those expression are taken as a parameter by strtotime, and I guess that generates an error.

So my guess the issue is valid... what do you think?
To solve the issue I would almost revert the change: Remove the strtotime from there.

PS: The expression to allow dates up to tomorrow could also be << date("Y-m-d H:i", strtotime("tomorrow")) >>. That put into an LS question configuration (after this issue is solved) could be something like date_max: << strtotime("tomorrow") >>

mfaber

mfaber

2015-04-22 15:16

reporter   ~32037

Gabrieljenik: The error comes because date('Y-m-d') + 1 is not a valid expression because it would be like adding "1" to the string "2015-04-22". The expression "date("Y-m-d H:i", strtotime("now")+606024)" works well.

Entering strtotime("tomorrow") will not work for two reasons:
1) We're using phpjs to have strtotime available in javascript for same page calculation/validation. The implementation in the phpjs library is not complete and strtotime("tomorrow") is not supported.

2) In the datemin/max field you need to enter a valid dateSTRING such as "2015-04-22" or "22.04.2015" or an expression that will produce such a string. Strtotime will produce the number of seconds since 1970, so this needs further conversion via function date().

gabrieljenik

gabrieljenik

2015-04-22 15:53

manager   ~32038

Sorry, you are right.

Related Changesets

LimeSurvey: master 4b7f15e4

2015-03-31 18:27:34

gabrieljenik

Details Diff
Fixed issue 09591: Sometimes date_max / date_min validations for date/time questions doesn't allow to use the maximum date expected.

- Reformat expression held into date_max / date_min into "Y-m-d H:i" format, so comparison can be done among equals format.
Affected Issues
09591
mod - application/helpers/expressions/em_manager_helper.php Diff File

LimeSurvey: master 202f68f4

2015-03-31 21:01:58

mfaber


Committer: mfaber Details Diff
Merge pull request #298 from gabrieljenik/patch-11

Fixed issue 09591: Sometimes date_max / date_min validations for date/t...
Affected Issues
09591
mod - application/helpers/expressions/em_manager_helper.php Diff File

LimeSurvey: 2.06 2d6849a8

2015-03-31 21:21:00

gabrieljenik

Details Diff
Fixed issue 09591: Sometimes date_max / date_min validations for date/time questions doesn't allow to use the maximum date expected.

- Reformat expression held into date_max / date_min into "Y-m-d H:i" format, so comparison can be done among equals format.
- Now min_date / max_date supports all the date formats correctly parsed by strtotime: YYYY-MM-DD, YYYY/MM/DD, DD.MM.YYYY, MM/DD/YYYY, DD-MM-YYYY, US natural language, ...
Affected Issues
09591
mod - application/helpers/expressions/em_manager_helper.php Diff File

LimeSurvey: 2.06 229abfd5

2015-03-31 21:36:03

mfaber


Committer: mfaber Details Diff
Merge pull request #299 from gabrieljenik/patch-12

Fixed issue 09591: Sometimes date_max / date_min validations for date/ti...
Affected Issues
09591
mod - application/helpers/expressions/em_manager_helper.php Diff File

Issue History

Date Modified Username Field Change
2015-03-27 18:55 gabrieljenik New Issue
2015-03-27 18:55 gabrieljenik Status new => assigned
2015-03-27 18:55 gabrieljenik Assigned To => gabrieljenik
2015-03-27 18:55 gabrieljenik File Added: limesurvey_question_3594.lsq
2015-03-27 20:30 mfaber Note Added: 31922
2015-03-27 21:24 mfaber Note Edited: 31922
2015-03-27 21:29 mfaber Issue Monitored: mfaber
2015-03-31 20:29 gabrieljenik Note Added: 31931
2015-03-31 20:30 gabrieljenik Status assigned => resolved
2015-03-31 20:30 gabrieljenik Resolution open => fixed
2015-03-31 23:02 gabrieljenik Changeset attached => LimeSurvey master 4b7f15e4
2015-03-31 23:02 mfaber Changeset attached => LimeSurvey master 202f68f4
2015-03-31 23:02 gabrieljenik Note Added: 31932
2015-03-31 23:02 mfaber Note Added: 31933
2015-03-31 23:02 mfaber Assigned To gabrieljenik => mfaber
2015-03-31 23:22 gabrieljenik Note Added: 31934
2015-03-31 23:36 gabrieljenik Changeset attached => LimeSurvey 2.06 2d6849a8
2015-03-31 23:36 mfaber Changeset attached => LimeSurvey 2.06 229abfd5
2015-03-31 23:36 mfaber Note Added: 31935
2015-04-21 10:51 c_schmitz Note Added: 32025
2015-04-21 10:51 c_schmitz Status resolved => feedback
2015-04-21 10:51 c_schmitz Resolution fixed => reopened
2015-04-21 13:13 mfaber Note Added: 32029
2015-04-21 14:10 c_schmitz Note Added: 32030
2015-04-21 14:10 c_schmitz Status feedback => closed
2015-04-21 14:10 c_schmitz Resolution reopened => fixed
2015-04-21 19:08 gabrieljenik Note Added: 32032
2015-04-21 19:08 gabrieljenik Status closed => feedback
2015-04-21 19:08 gabrieljenik Resolution fixed => reopened
2015-04-22 15:16 mfaber Note Added: 32037
2015-04-22 15:53 gabrieljenik Note Added: 32038
2015-04-22 15:53 gabrieljenik Status feedback => assigned
2015-04-22 16:07 mfaber Status assigned => resolved
2015-04-22 16:07 mfaber Resolution reopened => no change required
2015-04-22 16:07 mfaber Status resolved => closed
2015-06-20 12:16 mfaber Relationship added related to 09701
2021-08-02 17:19 guest Bug heat 6 => 8