The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
vbdate and negative unix timestamp?
I am having an issue with a mod displaying the date incorrectly when the unix timestamp is a negative value. Is vbdate setup to handle the negative unix timestamp correctly?
The value of $thispurchdate is -224406000 (11/21/1962) After the line is run below $purchase_date shows up as 12/31/1969. Code:
$purchase_date = vbdate($vbulletin->options['dateformat'], $thispurchdate, true); Code:
// ############################################################################# /** * Formats a UNIX timestamp into a human-readable string according to vBulletin prefs * * Note: Ifvbdate() is called with a date format other than than one in $vbulletin->options[], * set $locale to false unless you dynamically set the date() and strftime() formats in the vbdate() call. * * @param string Date format string (same syntax as PHP's date() function) * @param integer Unix time stamp * @param boolean If true, attempt to show strings like "Yesterday, 12pm" instead of full date string * @param boolean If true, and user has a language locale, use strftime() to generate language specific dates * @param boolean If true, don't adjust time to user's adjusted time .. (think gmdate instead of date!) * @param boolean If true, uses gmstrftime() and gmdate() instead of strftime() and date() * @param array If set, use specified info instead of $vbulletin->userinfo * * @return string Formatted date string */ function vbdate($format, $timestamp = TIMENOW, $doyestoday = false, $locale = true, $adjust = true, $gmdate = false, $userinfo = '') { global $vbulletin, $vbphrase; $uselocale = false; if (defined('VB_API') AND VB_API === true) { $doyestoday = false; } if (is_array($userinfo) AND !empty($userinfo)) { if ($userinfo['lang_locale']) { $uselocale = true; $currentlocale = setlocale(LC_TIME, 0); setlocale(LC_TIME, $userinfo['lang_locale']); if (substr($userinfo['lang_locale'], 0, 5) != 'tr_TR') { setlocale(LC_CTYPE, $userinfo['lang_locale']); } } if ($userinfo['dstonoff']) { // DST is on, add an hour $userinfo['timezoneoffset']++; if (substr($userinfo['timezoneoffset'], 0, 1) != '-') { // recorrect so that it has a + sign, if necessary $userinfo['timezoneoffset'] = '+' . $userinfo['timezoneoffset']; } } $hourdiff = (date('Z', TIMENOW) / 3600 - $userinfo['timezoneoffset']) * 3600; } else { $hourdiff = $vbulletin->options['hourdiff']; if ($vbulletin->userinfo['lang_locale'] AND !(defined('VB_API') AND VB_API === true)) { $uselocale = true; } } if ($uselocale AND $locale) { if ($gmdate) { $datefunc = 'gmstrftime'; } else { $datefunc = 'strftime'; } } else { if ($gmdate) { $datefunc = 'gmdate'; } else { $datefunc = 'date'; } } if (!$adjust) { $hourdiff = 0; } $timestamp_adjusted = max(0, $timestamp - $hourdiff); if ($format == $vbulletin->options['dateformat'] AND $doyestoday AND $vbulletin->options['yestoday']) { if ($vbulletin->options['yestoday'] == 1) { if (!defined('TODAYDATE')) { define ('TODAYDATE', vbdate('n-j-Y', TIMENOW, false, false)); define ('YESTDATE', vbdate('n-j-Y', TIMENOW - 86400, false, false)); define ('TOMDATE', vbdate('n-j-Y', TIMENOW + 86400, false, false)); } $datetest = @date('n-j-Y', $timestamp - $hourdiff); if ($datetest == TODAYDATE) { $returndate = $vbphrase['today']; } else if ($datetest == YESTDATE) { $returndate = $vbphrase['yesterday']; } else { $returndate = $datefunc($format, $timestamp_adjusted); } } else { $timediff = TIMENOW - $timestamp; if ($timediff >= 0) { if ($timediff < 120) { $returndate = $vbphrase['1_minute_ago']; } else if ($timediff < 3600) { $returndate = construct_phrase($vbphrase['x_minutes_ago'], intval($timediff / 60)); } else if ($timediff < 7200) { $returndate = $vbphrase['1_hour_ago']; } else if ($timediff < 86400) { $returndate = construct_phrase($vbphrase['x_hours_ago'], intval($timediff / 3600)); } else if ($timediff < 172800) { $returndate = $vbphrase['1_day_ago']; } else if ($timediff < 604800) { $returndate = construct_phrase($vbphrase['x_days_ago'], intval($timediff / 86400)); } else if ($timediff < 1209600) { $returndate = $vbphrase['1_week_ago']; } else if ($timediff < 3024000) { $returndate = construct_phrase($vbphrase['x_weeks_ago'], intval($timediff / 604900)); } else { $returndate = $datefunc($format, $timestamp_adjusted); } } else { $returndate = $datefunc($format, $timestamp_adjusted); } } } else { $returndate = $datefunc($format, $timestamp_adjusted); } if (!empty($userinfo['lang_locale'])) { setlocale(LC_TIME, $currentlocale); if (substr($currentlocale, 0, 5) != 'tr_TR') { setlocale(LC_CTYPE, $currentlocale); } } return $returndate; } |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|