News:

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

Main Menu

Relative Dates

Started by vbgamer45, February 07, 2010, 11:32:08 PM

Previous topic - Next topic

live627

Quote from: Eclipse16V on March 15, 2010, 02:15:42 AM
Nice Mod

Please update it for SMF 2.0RC3  ;)

Thanks
works as intended in compatibility mode

dannbass

There is an issue with Spanish, in order to make it work we would need "ago 15 hours" because it doesn't make that much sense "15 horas hace"
Would you help me reordering this?

// Numbers need language strings, too
            if ($seconds > 0)
            {
               if ($hours > 0 && $minutes > 59)
                  $retVal = $hours . ' ' . ($hours == 1 ? $txt['hour'] : $txt['hours']) . '  ' . $txt['ago'];
               elseif ($minutes > 0 && $seconds > 59)
                  $retVal = $minutes . ' ' . ($minutes == 1 ? $txt['minute'] : $txt['minutes']) . '  ' . $txt['ago'];
               else
                  $retVal = $seconds . ' ' . ($seconds == 1 ? $txt['second'] : $txt['seconds']) . '  ' . $txt['ago'];
            }


Thank you!!

live627

Sorry for the late reply. Here it is.

// Numbers need language strings, too
            
if ($seconds 0)
            {
               if (
$hours && $minutes 59)
                  
$retVal $txt['ago'] . '  ' $hours ' ' . ($hours == $txt['hour'] : $txt['hours']);
               elseif (
$minutes && $seconds 59)
                  
$retVal $txt['ago'] . '  ' $minutes ' ' . ($minutes == $txt['minute'] : $txt['minutes']);
               else
                  
$retVal $txt['ago'] . '  ' $seconds ' ' . ($seconds == $txt['second'] : $txt['seconds']);
            }

dannbass

Thank you!! that did it!!

Neverhurry

I translate the text into Chinese, but i don't know in which file i should put them to. Pls help.
(I install it but it works only in English language) Thanks.


$txt['hours'] = '小时';
$txt['minutes'] = '分';
$txt['seconds'] = '秒';
$txt['hour'] = '小时';
$txt['minute'] = '分';
$txt['second'] = '秒';
$txt['ago'] = '以前';
$txt['in'] = '在';
$txt['relative_today'] = '今天的相对时间';
I am using SMF 2.0.1, curve themes.

live627

Not sure, but try index.chinese.php

~DS~

I am getting some errors in the logs if you are on different languages other than english:
8: Undefined index: ago
File: /Sources/Subs.php
Line: 789


Same line with "8: Undefined index: seconds"
"There is no god, and that's the simple truth. If every trace of any single religion were wiped out and nothing were passed on, it would never be created exactly that way again. There might be some other nonsense in its place, but not that exact nonsense. If all of science were wiped out, it would still be true and someone would find a way to figure it all out again."
~Penn Jillette – God, NO! – 2011

live627

The strings are clearly missing. If, for example, you use Spanish, you'd need to add the respective strings into Modifications.spanish_latin.php.

* live627 had a first impulse of something sarcastic ::)

WasdMan

Addition days: ( install20.xml )

// Same day of the year, same year.... Today!
	
	
if (
$then['yday'] == $now['yday'] && $then['year'] == $now['year'])
	
	
{
	
	
	
// SMF has room for relative dates, no?
	
	
	
if (
$modSettings['todayMod'] == 3)
	
	
	
{
	
	
	
	
// Deetermine the relative dates
	
	
	
	
$seconds $nowtime $time;
	
	
	
	
$minutes floor($seconds 60);
	
	
	
	
$hours floor($minutes 60);
	
	
	
	
$days floor($days 24);

	
	
	
	
// Numbers need language strings, too
	
	
	
	
if (
$seconds 0)
	
	
	
	
{
	
	
	
	
	
if (
$days && $hours 24)
	
	
	
	
	
	
$retVal $days ' ' . ($days == $txt['day'] : $txt['days']) . '  ' $txt['ago'];
	
	
	
	
	
if (
$hours && $minutes 59)
	
	
	
	
	
	
$retVal $hours ' ' . ($hours == $txt['hour'] : $txt['hours']) . '  ' $txt['ago'];
	
	
	
	
	
elseif (
$minutes && $seconds 59)
	
	
	
	
	
	
$retVal $minutes ' ' . ($minutes == $txt['minute'] : $txt['minutes']) . '  ' $txt['ago'];
	
	
	
	
	
else
	
	
	
	
	
	
$retVal $seconds ' ' . ($seconds == $txt['second'] : $txt['seconds']) . '  ' $txt['ago'];
	
	
	
	
}
	
	
	
	
// Time is in the future so rework :P
	
	
	
	
else
	
	
	
	
{
	
	
	
	
	
$seconds $time $nowtime;
	
	
	
	
	
$minutes floor($seconds 60);
	
	
	
	
	
$hours floor($minutes 60);
	
	
	
	
	
if (
$days && $hours 24)
	
	
	
	
	
	
$retVal $txt['in'] . '  ' $days ' ' . ($days == $txt['day'] : $txt['days']);
	
	
	
	
	
if (
$hours && $minutes 59)
	
	
	
	
	
	
$retVal $txt['in'] . '  ' $hours ' ' . ($hours == $txt['hour'] : $txt['hours']);
	
	
	
	
	
elseif (
$minutes && $seconds 59)
	
	
	
	
	
	
$retVal $txt['in'] . '  ' $minutes ' ' . ($minutes == $txt['minute'] : $txt['minutes']);
	
	
	
	
	
else
	
	
	
	
	
	
$retVal $txt['in'] . '  ' $seconds ' ' . ($seconds == $txt['second'] : $txt['seconds']);
	
	
	
	
}
	
	
	
}
	
	
	
// Defaults FTW!
	
	
	
else
	
	
	
	
$retVal $txt['today'] . timeformat($log_time$today_fmt$offset_type);

	
	
	
return 
$retVal;
	
	
}


Addition of language: ( english.xml )


$txt
['days'] = 'days';
$txt['hours'] = 'hours';
$txt['minutes'] = 'minutes';
$txt['seconds'] = 'seconds';
$txt['day'] = 'day';
$txt['hour'] = 'hour';
$txt['minute'] = 'minute';
$txt['second'] = 'second';
$txt['ago'] = 'ago';
$txt['in'] = 'in';
$txt['relative_today'] = 'Today with relative times';

Biology Forums

Is there a way of including both relative dates of today and the word "yesterday" for anything older than a day but less than 48 hours?

Biology Forums

Got it to work, simply:

Find
// SMF has room for relative dates, no?
if ($modSettings['todayMod'] == 3)


Replace with:
// SMF has room for relative dates, no?
if ($modSettings['todayMod'] == 2)

WasdMan

I attached the Hungarian language.

SilverKnight

Great Mod, just what i was searching for. Can you make it so it also takes into consideration weeks and months as well?

So 2 days ago, 2 weeks ago, 1 month ago etc.

Jessica.

Quote from: SilverKnight on March 10, 2012, 02:52:12 AM
Great Mod, just what i was searching for. Can you make it so it also takes into consideration weeks and months as well?

So 2 days ago, 2 weeks ago, 1 month ago etc.

eh no I don't want that
Testing Zone - SMF 2.0.7, default Curve
School & Chat - phpBB3, over 170 mods installed, official live forum

I use the latest version of Chrome

phpBB: Forum = a section; Board = whole site
SMF: Forum = whole site; Board = a section

Biology Forums

Quote from: SilverKnight on March 10, 2012, 02:52:12 AM
Great Mod, just what i was searching for. Can you make it so it also takes into consideration weeks and months as well?

So 2 days ago, 2 weeks ago, 1 month ago etc.

It shouldn't be too difficult to put together, all you'd need is the mathematics formula to calculate how many seconds are in a week, month, year, etc.

SilverKnight

Has anyone noticed this mod being buggy? Such as relative time randomly disappearing and being replaced by old date, so even if something was posted a few minutes ago it defaults back? It's really weird and annoying to go from minutes to date of the day.

Biology Forums

Quote from: SilverKnight on March 11, 2012, 09:12:26 PM
Has anyone noticed this mod being buggy? Such as relative time randomly disappearing and being replaced by old date, so even if something was posted a few minutes ago it defaults back? It's really weird and annoying to go from minutes to date of the day.

Never happened to me :-\

SilverKnight

#37

live627

Quote from: Liam_michael on March 11, 2012, 09:55:32 PM
Quote from: SilverKnight on March 11, 2012, 09:12:26 PM
Has anyone noticed this mod being buggy? Such as relative time randomly disappearing and being replaced by old date, so even if something was posted a few minutes ago it defaults back? It's really weird and annoying to go from minutes to date of the day.

Never happened to me :-\
Me neither, and  I have ~60 mods installed.

Quote from: SilverKnight on March 11, 2012, 10:52:12 PM
Quote from: WasdMan on March 13, 2011, 07:23:41 AM-snip-

Good addition.
It won't  work, though.

SilverKnight

#39
Sadly it doesn't, just tested it, could you add a days feature to the mod that does work?

-snip- It's working properly now.

Advertisement: