Jump to content



Issue Information

  • #000537

  • 0 - None Assigned

  • New

  • 2.3.3

  • -

Issue Confirmations

  • Yes (0)No (0)
Photo

function tep_date_long will quit working after the year 2038

Posted by wdepot on 31 October 2012 - 11:38 PM

This is probably low priority since we have a few years left until 2038 but eventually this will need to be addressed. While the tep_date_short function has a fix for years after 2037 the tep_date_long function does not and will produce some odd results once the date exceeds the capabilities of the mktime function. However I've discovered that the function can be fixed using the built in PHP Julian date functions which work for dates through the year 9999.

Simply replace at the end of the function:

return strftime(DATE_FORMAT_LONG, mktime($hour,$minute,$second,$month,$day,$year));

with the following:


    $JD = gregoriantojd($month, $day, $year);
    $mname = jdmonthname($JD, 1);
    $wdname = jddayofweek($JD, 1);
    $day = sprintf('%02d' , $day);
    $year = sprintf('%04d' , $year);
    $x = DATE_FORMAT_LONG;
    return preg_replace(array('/\%A/', '/\%d/', '/\%B/', '/\%Y/'), array($wdname, $day, $mname, $year), $x);

No doubt the original functionality can be retained.  
The Terminator will have destroyed the Skynet by 2038.

Are you on a 32bit system?

Nope, we use a 64bit version of  SME Server.