Our filter for displaying pages by month started returning a "The day is invalid" error today, 1 February. Because the month filter is really for content published between first and last day of month, if you filter for content in month with last date greater than 28th (ie any month except the current month, February) the error is displayed.

Confirmed on a plain D7 site with latest versions of Views, Date API and Date Views modules

Steps to reproduce:
- create new Drupal 7 site
- enable Views, Date API and Date Views modules
- create new View, type 'node'
- add page to view
- set path
- set row style to 'node'
- add 'Date (none)' filter
- select 'Node: post date' … update
- operator "is between"
- "Expose"
- "Update and override"
- Save the view
- go to the view
- from date: Jan 1 2011
- to date: Jan 31 2011
- Apply

I've tested this in both alpha1 and alpha2.

As we're currently using alpha1 I narrowed it down to:

./date_api.module:597: $errors['day'] = t('The day is invalid.');

It would appear that in the methods arrayErrors() & forceValid() it is testing whether '31' is a valid day, but it is testing it against $now, which is February, so it fails.

Thanks,
Tim

CommentFileSizeAuthor
#6 date-fix-arrayErrors-1047412-6.patch973 bytesdas-peter

Comments

lomo’s picture

We are seeing this issue, too. I was just going to report the same thing.

I think this is actually a "critical" issue since a lot of dates are now being rejected as invalid; dates which are actually perfectly valid input. Should be a fairly simple fix, though...

enikola’s picture

Priority: Normal » Critical

sub

mattcoady’s picture

I also got this as well. Sub. Today's date worked.

unknown interloper’s picture

I have the same issue.

April 29 and April 30 generate "The day is invalid" error.

I use Drupal in French, I don't know if it is related...

I changed the date format and also the date field type and these actions didn't help.

Any idea?

adaddinsane’s picture

At the risk of being unoriginal "me too". This is a serious problem. I need to create a list of UK bank holidays, one of which is the last Monday of August = 29th. Ooops not allowed.

das-peter’s picture

Status: Active » Needs review
StatusFileSize
new973 bytes

Just came also across this - attached patch hopefully fixes this.

If there are usable values to work with they are used instead "now".

adaddinsane’s picture

Works for me - thanks.

timhomewood’s picture

The patch works, thanks das-peter.

jon betts’s picture

#6 patch works for me too, thanks! Oct 29-31 didn't work for me.

georgedamonkey’s picture

I can not only confirm the patch fixes this issue... But, it also fixes this one: http://drupal.org/node/1049976

Outstanding work, my friend!

wiizzard’s picture

#6 patch works for me too.

liberatr’s picture

Patch works for me too.

czigor’s picture

#6 works for me too.

enikola’s picture

Issue is present also in alpha2. Can somebody please confirm patch is working against alpha2.

enikola’s picture

Version: 7.x-1.0-alpha1 » 7.x-1.0-alpha2
georgedamonkey’s picture

I have alpha 2, and the patch worked perfectly.

jcarlson34’s picture

Status: Needs review » Reviewed & tested by the community

Works like a charm. Many thanks!

Looks like enough people reviewed this, lets get it into the next build. Marking RBTC

mukesh.agarwal17’s picture

Worked like a charm.. Thanks!

arlinsandbulte’s picture

Status: Reviewed & tested by the community » Needs review

Marked #1057116: Validation error "The day is invalid" even when it is not as a duplicate of this issue, which has code that is nearly identical to the patch in #6.

The only difference is this the use of !empty vs array_key_exists:
#6:
$default_month = !empty($arr['month']) ? $arr['month'] : $now->format('n');
$default_year = !empty($arr['year']) ? $arr['year'] : $now->format('Y');

#1057116: Validation error "The day is invalid" even when it is not:
$default_month = array_key_exists('month', $arr) ? $arr['month'] : $now->format('n');
$default_year = array_key_exists('year', $arr) ? $arr['year'] : $now->format('Y');

So, which method is best to use here?

das-peter’s picture

Hmm, good question.
Since array_key_exists also returns true if there's an empty value like NULL or 0 I think we should use !empty - because dealing with dates 0 isn't a valid value (or am I missing a case?).
Thus with !empty we have at least a chance that the right thing is done even if there's a empty value ;)

arlinsandbulte’s picture

Status: Needs review » Fixed

OK, sounds reasonable.
Committed #6: http://drupal.org/cvs?commit=498328

s_oneill’s picture

Someone like me, who ain't no drupal wizard needs to be told, where to apply this patch ... it ain't root folder!

tim.plunkett’s picture

s_oneill, try it from within the date_api folder. Or just grab the latest dev copy, its included

Renegadez’s picture

Tim is there a proper way to update to the new dev version like do I need to disable the module and uninstall it and then copy the new dev up to the server and reenable?? will doing this break an exisint dates? sorry still very new but do not want to break anything Thanks for the help Renz

tim.plunkett’s picture

renegadez, you can skip the uninstalling part. Just disable, remove the module folder, copy the new one up, re-enable, run update.php, and clear the caches.

Renegadez’s picture

Tim Thank you very much!

Ok the new dev version expcet somehow my second calendar using its own content type cannot make display posts made it to it. The dates are created they just dont show up on the calendar Ideleted the view and made a fresh one from scratch used all the setting from the working except substituted the content type for puc_cal instead or priv_cal i am ar a total loss why one could displayed correctly but the other cannot they both worked before except for the post on the 30th weird Thanks Renz

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.