Long story short, using date/date_pop with a date_format of 'Ymd' generate 'Year not valid'. After tracing through the code the culprit seems to be in date_api.module. function date_format_patters returns '-?\d{1,6}' for the key of 'Y'. I can't think of any instance where a year should be 6 digits. For my install I changed this to 'Y' => '-?\d{1,4}' and it works fine. I've tested it with 'Ymd' and 'Y-m-d' and both instances work. I have not tested with any other format so if this will break something else, please let me know. Also just as a side note, 'Y-m-d' works fine. it's only if there is no separator that I see this issue.

not working (for Ymd)

'Y' => '-?\d{1,6}'

working (for Ymd)

'Y' => '-?\d{1,4}'

UPDATE: patches included for date-7.x-2.6, date-7.x-2.8 and current dev (gngn, 2014-12-12)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

itsekhmistro’s picture

Issue summary: View changes
Status: Active » Needs review

I came up with the same patch for date_format_patters() :
'Y' => '-?\d{1,4}'

Could someone clarify in which case a six-digit long Year number ('Y' => '-?\d{1,6}') is possible?
Or its a long-live bug ? (seems it was originally posted https://drupal.org/node/1086240 but closed)

vijaycs85’s picture

Status: Needs review » Active

Back to active as per http://drupal.org/node/156119

hauruck’s picture

Same problem here, such a small change I could not resist trying to make a patch for the first time :-)

gngn’s picture

The same problem still occurs in 7.x-2.8 and current dev version.
And the same solution helped me.

So here is a patch for current dev.

btw: the issue is for 7.x-2.6 - so should I open a new issue with the patch?

gngn’s picture

Status: Active » Needs review

The last submitted patch, 3: date-Y-format-error-2053955-3.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 4: date-Y-format-error-2053955-4.patch, failed testing.

gngn’s picture

And another one for the current stable release 7.x-2.8

I also putting this to "Needs review".
I think the automatic test failedbecause of the wrong version number, so I'm also changing this to 7.x-2.8.
Or should I change the version back, create another issue for dev and/or current stable or...?

And I'm also interested if a six-digit long Year number makes sense anywhere ;)

gngn’s picture

Status: Needs work » Needs review
awolfey’s picture

Works for me. Thanks.

steinmb’s picture

Version: 7.x-2.8 » 7.x-2.x-dev
steinmb’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
19.74 KB
44.89 KB

Patch still apply cleanly

Before applying patch

Goto /admin/config/regional/date-time/formats and add the custom formats: Y.m.d, Y-m-d and Ymd

Both Y.m.d and Y-m-d works without the patch. Ymd does now.

After applying the patch all three works. RTBC from me. Not sure if there should be tests for these formats?

DamienMcKenna’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

I think some brief test coverage would be useful for this.