Skip to content

Instantly share code, notes, and snippets.

@waldoj
Created June 3, 2013 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waldoj/5699321 to your computer and use it in GitHub Desktop.
Save waldoj/5699321 to your computer and use it in GitHub Desktop.
Actual code segment from ExpressionEngine, found within /expressionengine/expressionengine/libraries/Localize.php, in convert_human_date_to_gmt(). I tracked it down in an effort to fix the software's inability to store dates from prior to 1902 <http://ellislab.com/forums/viewthread/74033>, which they had blamed on everybody but themselves.
if ($year < 1902 OR $year > 2037)
{
return $this->EE->lang->line('date_outside_of_range');
}
@adrienne
Copy link

adrienne commented Jun 3, 2013

Nope, this is actually important, because otherwise dates outside that range will still be bound to the range. Now, mind you, the date issue is still their FAULT for using integers to store dates, but this piece of code isn't actually the culprit -- it's sensible error-handling given the limitations imposed by their other design decisions.

@waldoj
Copy link
Author

waldoj commented Jun 5, 2013

I think that's pretty easily addressed by PHP's PHP_INT_SIZE constant, which exists for just this purpose:

if ( (PHP_INT_SIZE == 4) && ($year < 1902 OR $year > 2037) )
{
    return $this->EE->lang->line('date_outside_of_range');
}

That way, only folks on 32-bit environments are bound to the range, while the rest of us can have proper dates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment