============================================================================================================================
Title: Last Post Date Upgrade

Version: 1.0

Author: Adam Clarke

Description:
This modification will change the display format of the last post.
If the last post was made within 7 days it will display: Today, Yesterday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, or Sunday.
Any older posts will diplay the date as normal.

Copyright:  2009 Adam Clarke. All rights reserved.

Compatibility: XMB 1.9.8 SP4

Install Note: Before adding this modification to your forum you should back up all files related to this modification.

License Note: This modification is released under the GPL v3 License. A copy is provided with this software package.

Author Note: This modification is developed and released for use with XMB 1.9.8 SP4 which is provided by XMBGarage.com.

============================================================================================================================
=======
Step 1:
=======
=========================
Edit File: include/functions.inc.php
=========================
==========
Find Code:
==========

function printGmDate($timestamp=null, $altFormat=null, $altOffset=0) {
    global $self, $dateformat, $SETTINGS, $timeoffset, $addtime;

    if ($timestamp === null) {
        $timestamp = time();
    }

    if ($altFormat === null) {
        $altFormat = $dateformat;
    }

    $f = false;
    if ((($pos = strpos($altFormat, 'F')) !== false && $f = true) || ($pos2 = strpos($altFormat, 'M')) !== false) {
        $startStr = substr($altFormat, 0, $pos);
        $endStr = substr($altFormat, $pos+1);
        $month = gmdate('m', $timestamp + ($timeoffset*3600)+(($altOffset+$addtime)*3600));
        $textM = month2text($month);
        return printGmDate($timestamp, $startStr, $altOffset).substr($textM,0, ($f ? strlen($textM) : 3)).printGmDate($timestamp, $endStr, $altOffset);
    } else {
        return gmdate($altFormat, $timestamp + ($timeoffset * 3600) + (($altOffset+$addtime) * 3600));
    }
}

==================
Replace Code With:
==================

// Last Post Date Upgrade Mod Begin

function printGmDate($timestamp=null, $altFormat=null, $altOffset=0) {
    global $dateformat, $SETTINGS, $timeoffset, $addtime, $lang, $onlinetime;

    if ($timestamp === null) {
        $timestamp = $onlinetime;
    }

    if ($altFormat === null) {
        $altFormat = $dateformat;
    }

    $now = $onlinetime;
    $today = gmmktime(0, 0, 0, gmdate('n', $now), gmdate('j', $now), gmdate('Y', $now)) - (($timeoffset*3600) + ($SETTINGS['addtime']*3600));;

    if ($timestamp >= $today) {
        return $lang['texttoday'];
    } else if ($timestamp >= ($today - 86400)) {
        return $lang['textyesterday'];
    } else if ($timestamp >= ($today - 518400)) {
        return $lang['text'.strtolower(gmdate('D', $timestamp + ($timeoffset * 3600) + ($SETTINGS['addtime'] * 3600)))];
    }

    $f = false;
    if ((($pos = strpos($altFormat, 'F')) !== false && $f = true) || ($pos2 = strpos($altFormat, 'M')) !== false) {
        $startStr = substr($altFormat, 0, $pos);
        $endStr = substr($altFormat, $pos+1);
        $month = gmdate('m', $timestamp + ($timeoffset*3600)+(($altOffset+$addtime)*3600));
        $textM = month2text($month);
        return printGmDate($timestamp, $startStr, $altOffset).substr($textM,0, ($f ? strlen($textM) : 3)).printGmDate($timestamp, $endStr, $altOffset);
    } else {
        return gmdate($altFormat, $timestamp + ($timeoffset * 3600) + (($altOffset+$addtime) * 3600));
    }
}
// Last Post Date Upgrade Mod End

==========
Find Code:
==========

        $lastpostdate = gmdate($dateformat, $lastpost[0] + ($timeoffset * 3600) + ($SETTINGS['addtime'] * 3600));

================
Replace Code With:
================

        $lastpostdate = printGmDate($lastpost[0]);

============================================================================================================================
=======
Step 2:
=======
=======================
Edit File: lang/English.lang.php
=======================
============================
Add Code To End Of File Above ?>
============================

// Last Post Date Upgrade Mod Begin
$lang['texttoday'] = "<strong>Today</strong>";
$lang['textyesterday'] = "<strong>Yesterday</strong>";
$lang['textmon'] = "Monday";
$lang['texttue'] = "Tuesday";
$lang['textwed'] = "Wednesday";
$lang['textthu'] = "Thursday";
$lang['textfri'] = "Friday";
$lang['textsat'] = "Saturday";
$lang['textsun'] = "Sunday";
// Last Post Date Upgrade Mod End

============================================================================================================================
=======
Step 3:
=======
=================
Edit File: activity.php
=================
==========
Find Code:
==========

    $lastpostdate = gmdate($dateformat, $lastpost[0] + $tmOffset);

================
Replace Code With:
================

    $lastpostdate = printGmDate($lastpost[0]);

============================================================================================================================
=======
Step 4:
=======
====================
Edit File: forumdisplay.php
====================
==========
Find Code:
==========

    $lastreplydate = gmdate($dateformat, $lastpost[0] + ($timeoffset * 3600) + ($addtime * 3600));

==================
Replace Code With:
==================

    $lastreplydate = printGmDate($lastpost[0]);

============================================================================================================================
Enjoy!