ReTAD - Relative Time And Date (Facebook Styles)

Started by Hj Ahmad Rasyid Hj Ismail, July 17, 2014, 03:47:03 PM

Previous topic - Next topic

Hj Ahmad Rasyid Hj Ismail

I think it will not be in conflict with that mod.

suhaneankit

7 Steps IRCTC Registration IRCTC Registration in 7 Steps
Check PNR Status IRCTC PNR Status

Hj Ahmad Rasyid Hj Ismail

It is just a simple mod that I think is useful but SMF will not implement something like this mod in 2.1 though.

Ataru Moroboshi

my penny, italian language:


$txt['rltv_years'] = ' anni fa';
$txt['rltv_months'] = ' mesi fa';
$txt['rltv_weeks'] = ' settimane fa';
$txt['rltv_days'] = ' giorni fa';
$txt['rltv_hours'] = ' ore fa';
$txt['rltv_minutes'] = ' minuti fa';
$txt['rltv_year'] = 'un anno fa';
$txt['rltv_month'] = 'un mese fa';
$txt['rltv_week'] = 'una settimana fa';
$txt['rltv_day'] = 'un giorno fa';
$txt['rltv_hour'] = 'un\'ora fa';
$txt['rltv_minute'] = 'un minuto fa';
$txt['rltv_second'] = 'pochi secondi fa';
$txt['rltv'] = 'Orario e Date Relative';
$txt['on'] = 'in proposito';

Hj Ahmad Rasyid Hj Ismail

Updated with new translation.

#Change log
@Version 1.2.3.1
-  Adding Italian language support, thanks to Ataru Moroboshi.

DSystem

I love this mod. I use since its launch.  ;)

I have some members complaining that they liked more the old-fashioned way.

Would it be possible to put an option in the profile where the Member can choose as the dates of the posts be displayed?

DSystem

I did this update.



I'm putting here the scripts changed.

Profile.template.php

Before:
<input type="text" name="time_offset" id="time_offset" size="5" maxlength="5" value="', $context['member']['time_offset'], '" class="input_text" /> <a href="javascript:void(0);" onclick="currentDate = new Date(', $context['current_forum_time_js'], '); document.getElementById(\'time_offset\').value = autoDetectTimeOffset(currentDate); return false;">', $txt['timeoffset_autodetect'], '</a><br />', $txt['current_time'], ': <em>', $context['current_forum_time'], '</em>
</dd>


Add after:
                            <dt>
<input type="hidden" name="default_options[rltv_disable]" value="0" />
<label for="rltv_disable"><input type="checkbox" name="default_options[rltv_disable]" id="rltv_disable" value="1"', !empty($context['member']['options']['rltv_disable']) ? ' checked="checked"' : '', ' class="input_check" /> ', $txt['rltv_disable'], '</label>
</dt>


Modifications.english.php

Add this line:
$txt['rltv_disable'] = 'Disable Relative Time And Date';

Subs.php

Before:
global $context, $user_info, $txt, $modSettings, $smcFunc;

Replace:
global $context, $user_info, $txt, $modSettings, $smcFunc, $options;

Before:
        if ($then['yday'] == $now['yday'] && $then['year'] == $now['year'])
return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type);


Replace:
        if (!empty($options['rltv_disable'])) {
        // Same day of the year, same year.... Today!
        if ($then['yday'] == $now['yday'] && $then['year'] == $now['year'])
return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type);
       } else {

        // Relative Time And Date Mod Starts
$rltv_time = $nowtime - $time;
$rltv_date = floor($rltv_time / 86400);
if (($then['yday'] == $now['yday'] && $then['year'] == $now['year']) ||  ($rltv_time > 0 && $rltv_date == 0))
{
if ($modSettings['todayMod'] == 3)
{
if($rltv_time < 60) return $txt['rltv_second'];
if($rltv_time < 120) return $txt['rltv_minute'];
if($rltv_time < 3600) return floor($rltv_time / 60) . $txt['rltv_minutes'];
if($rltv_time < 7200) return $txt['rltv_hour'];
if($rltv_time < 86400) return floor($rltv_time / 3600) . $txt['rltv_hours'];
}
else
{
$rltv_time = $txt['today'] . timeformat($log_time, $today_fmt, $offset_type);
return $rltv_time;
}
}
if ($modSettings['todayMod'] == 3 && $rltv_time > 0 && $rltv_date > 0)
{
if($rltv_date < 2) return $txt['rltv_day'];
if($rltv_date < 7) return floor($rltv_date) . $txt['rltv_days'];
if($rltv_date < 14) return $txt['rltv_week'];
if($rltv_date < 30) return floor($rltv_date / 7) . $txt['rltv_weeks'];
if($rltv_date < 60) return $txt['rltv_month'];
if($rltv_date < 365) return floor($rltv_date / 31) .  $txt['rltv_months'];
if($rltv_date < 730) return $txt['rltv_year'];
if($rltv_date > 730) return floor($rltv_date / 365) .  $txt['rltv_years'];
} }
// Relative Time And Date Mod Ends


It was perfect. :D

Hj Ahmad Rasyid Hj Ismail

Nice one, though I didn't test that. There may be other better way to do that too. :)

confuseamuse

Is there a way to have the actual date and time appear when a user hovers over the text?

confuseamuse

Quote from: confuseamuse on July 06, 2017, 05:21:50 AM
Is there a way to have the actual date and time appear when a user hovers over the text?

I've referred to this requested feature in this thread (if anyone was interested).

confuseamuse

So I managed to get the tooltip to show. What is the format to get the post date to show? All it does is show the current time (rendering it completely useless). Here's a visual example:



This date is obviously wrong, so when I activate ReTAD it does this:




<div class="smalltext"><a href="', $message['href'], '" rel="nofollow" title="',timeformat(time(),'%a %e %b, %Y - %T' , $message['time']), '">', $message['time'], '</a></div>

confuseamuse

Can someone make an edit of this mod that separates it from the shorthand settings.

I figured out that in order for the tooltip to work, it needs to have a detailed version of the mod working. As a result, this means that I'd manually have to edit the display.template.php and BoardIndex.template.php files and choose where I want the mod to apply itself.

I tried doing this edit, but it just brought a blank page with an error message in the logs. I'm learning the basics of coding for HTML/CSS before getting into PHP/Javascript territory, so I'm not sure how to use the PHP syntax as of now.

Advertisement: