News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

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

Since we got three translations now, I will put all of them with the mod.

Edited: Updated to version 1.1.1 with Spanish_Latin, Dutch & Malay languages added.

Biology Forums

A small tweak request.

Instead of 12 months ago, it gets changed to "A year ago".

Hj Ahmad Rasyid Hj Ismail

There aren't suppose to be 12 months ago. ??? The months are called only if they are below 365 days. Divided by 31, they can never be 12 months IMO.

if ($modSettings['todayMod'] == 3 && $itv > 0 && $day_itv > 0)
{
if($day_itv < 2) return $txt['itv_day'];
if($day_itv < 7) return $day_itv . $txt['itv_days'];
if($day_itv < 13) return $txt['itv_week'];
if($day_itv < 31) return ceil($day_itv / 7) . $txt['itv_weeks'];
if($day_itv < 60) return $txt['itv_month'];
if($day_itv < 365) return ceil($day_itv / 31) . $txt['itv_months'];
if($day_itv < 730) return $txt['itv_year'];
if($day_itv > 730) return ceil($day_itv / 365) . $txt['itv_years'];
}


If you need the 12 months, you must change  / 31 to / 30. That will give 5 days extra before it turns to a year. Is that what you want, Shuban?

Mstcool

Quote from: ahrasis on August 14, 2014, 09:33:16 AM
That is why I am trying to drop the one with time details. It is a little bit confusing to have them both in there.
Quote from: ahrasis on August 14, 2014, 09:33:16 AM
That is why I am trying to drop the one with time details. It is a little bit confusing to have them both in there.

Why don't you so simply put the time details file download link in your post rather than having it on the mod site? :P


Hj Ahmad Rasyid Hj Ismail

I don't get it and I am not sure why. I can see some is already using a year. But I will try to find out why, later.

Quote from: Mstcool on August 25, 2014, 01:26:11 PM
Quote from: ahrasis on August 14, 2014, 09:33:16 AM
That is why I am trying to drop the one with time details. It is a little bit confusing to have them both in there.
Quote from: ahrasis on August 14, 2014, 09:33:16 AM
That is why I am trying to drop the one with time details. It is a little bit confusing to have them both in there.
Why don't you so simply put the time details file download link in your post rather than having it on the mod site? :P

???


Mstcool

In this thread, simply put a download link to the mod (the mod with the times details) and remove the file from the mod site.

Hj Ahmad Rasyid Hj Ismail

I guess you have to read more then. I dropped the one with time details already but due to the user confusion, I re-uploaded it back. My intention was to remove the one with time details completely. I will implement that again later without any confusing statement. Looking to fix Shuban's 'error' for now.

Mstcool

Quote from: ahrasis on August 26, 2014, 03:28:08 AM
I guess you have to read more then. I dropped the one with time details already but due to the user confusion, I re-uploaded it back. My intention was to remove the one with time details completely. I will implement that again later without any confusing statement. Looking to fix Shuban's 'error' for now.

Oh, I know. I read all of your posts, don't worry lol. But I just meant, if you want to include it then just attach it to your post. p

Hj Ahmad Rasyid Hj Ismail

Oh. Now I get your point. Anyway, I will leave it as it is for a while longer.

Biology Forums

I'm finding that this mod if displaying years incorrectly. For example, if someone has signed up for 4 years and 2 months, for instance, it will state 5 years ago. I noticed this because my forum has been alive for four years and two months, and in the admin's profile - the very first member - it states five years ago.

Hj Ahmad Rasyid Hj Ismail

 Thank you for the feedback Shuban. I will check that out.

Edited: It has been a while after I code this and I have forgotten its cod. But after a thorough check and refreshment, I find that this mod wasn't designed to cover the number of day/s once, it reaches week/s. Similarly to weeks/s and month/s when it reaches month/s and year/s. The mod have to be upgraded to achieve that.

As for your earlier 12 months problem, though I can see it clearly in your forum, I couldn't find a way to fix it yet. I am attending to it as we speak.


Hj Ahmad Rasyid Hj Ismail

Shuban, this is an attempt to fix the 12 months issue. I have tested this code with no errors but I will need you to test it on your forum. You can start by replacing the current code manually with this in Subs.php file:

// Improved Displayed Times Mod Starts
$itv = $nowtime - $time;
$day_itv = floor($itv / 86400);
if (($then['yday'] == $now['yday'] && $then['year'] == $now['year']) || ($itv > 0 && $day_itv == 0))
{
if ($modSettings['todayMod'] == 3)
{
if($itv < 60) return $txt['itv_second'];
elseif($itv > 60 && $itv < 120) return $txt['itv_minute'];
elseif($itv > 120 && $itv < 3600) return floor($itv / 60) . $txt['itv_minutes'];
elseif($itv > 3600 && $itv < 7200) return $txt['itv_hour'];
elseif($itv > 7200 && $itv < 86400) return floor($itv / 3600) . $txt['itv_hours'];
}
else
{
$itv = $txt['smf10'] . timeformat($logTime, $today_fmt);
return $itv;
}
}
elseif ($modSettings['todayMod'] == 3 && $itv > 0 && $day_itv > 0)
{
if($day_itv < 2) return $txt['itv_day'];
elseif($day_itv > 2 && $day_itv < 7) return $day_itv . $txt['itv_days'];
elseif($day_itv > 6 && $day_itv < 14) return $txt['itv_week'];
elseif($day_itv > 13 && $day_itv < 30) return ceil($day_itv / 7) . $txt['itv_weeks'];
elseif($day_itv > 29 && $day_itv < 60) return $txt['itv_month'];
elseif($day_itv > 59 && $day_itv < 365) return ceil($day_itv / 31) .  $txt['itv_months'];
elseif($day_itv > 364 && $day_itv < 730) return $txt['itv_year'];
elseif($day_itv > 729 && $day_itv > 730) return ceil($day_itv / 365) .  $txt['itv_years'];
}
// Improved Displayed Times Mod Ends


I hope to see it fixes your problem and not creating a new one. Please update here once you have fully tested it. If everything is fine on your side, I will update this mod with the above code.

Biology Forums

The 12 months ago still shows, and the 4 years 5 years issue is still there.

Hj Ahmad Rasyid Hj Ismail

Ok, now I think I know the problem. Maybe we have to change ceil to floor. Can you try this instead?

// Improved Displayed Times Mod Starts
$itv = $nowtime - $time;
$day_itv = floor($itv / 86400);
if (($then['yday'] == $now['yday'] && $then['year'] == $now['year']) || ($itv > 0 && $day_itv == 0))
{
if ($modSettings['todayMod'] == 3)
{
if($itv < 60) return $txt['itv_second'];
elseif($itv > 60 && $itv < 120) return $txt['itv_minute'];
elseif($itv > 120 && $itv < 3600) return floor($itv / 60) . $txt['itv_minutes'];
elseif($itv > 3600 && $itv < 7200) return $txt['itv_hour'];
elseif($itv > 7200 && $itv < 86400) return floor($itv / 3600) . $txt['itv_hours'];
}
else
{
$itv = $txt['smf10'] . timeformat($logTime, $today_fmt);
return $itv;
}
}
elseif ($modSettings['todayMod'] == 3 && $itv > 0 && $day_itv > 0)
{
if($day_itv < 2) return $txt['itv_day'];
elseif($day_itv > 2 && $day_itv < 7) return $day_itv . $txt['itv_days'];
elseif($day_itv > 6 && $day_itv < 14) return $txt['itv_week'];
elseif($day_itv > 13 && $day_itv < 30) return floor($day_itv / 7) . $txt['itv_weeks'];
elseif($day_itv > 29 && $day_itv < 60) return $txt['itv_month'];
elseif($day_itv > 59 && $day_itv < 365) return floor($day_itv / 31) .  $txt['itv_months'];
elseif($day_itv > 364 && $day_itv < 730) return $txt['itv_year'];
elseif($day_itv > 729 && $day_itv > 730) return floor($day_itv / 365) .  $txt['itv_years'];
}
// Improved Displayed Times Mod Ends


Hj Ahmad Rasyid Hj Ismail

Ok then. That finalized it. It will be in the coming 1.2.0 version.

Hj Ahmad Rasyid Hj Ismail

Mod is updated to version 1.2.0. It fixed the issues of time wrongly displayed as reported by Shuban.

I hope more can come to report any failure with regards to this mod and/or my other mods without hesitation.

Thank you all for your continuous support by using this simple mod and/or my other mods.

Advertisement: