News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Relative Dates

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

Previous topic - Next topic

ocmdiaz714

#40
Quote from: WasdMan on March 13, 2011, 07:23:41 AM
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';


I went ahead and added the modified bit to my language, and subs file, but nothing. :(

Here's what I have:


// 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($hours / 24);

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

return $retVal;
}


I think it has something to do with the "if" tags.
EDIT: Also, after making a post I'm shown with a "in 0 seconds" display, is there any way to change to..."just now"? Thanks.

ocmdiaz714


Rain Forest

Thank you! Im using this mod right now :)

ocmdiaz714

Quote from: Liam_michael on March 10, 2012, 06:45:36 PM
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.

Any idea on how I can add days?

Biology Forums

This mod really needs to be updated to include this week, this month, etc.

Anyone interested in this?

TheListener

Quote from: Liam_michael on June 08, 2013, 07:19:57 PM
This mod really needs to be updated to include this week, this month, etc.

Anyone interested in this?

Ya know the mods author is the only person whom can do this right?

I use the mod myself and believe it to be perfect as it is.

Rain Forest

Is there a way to include this for like 24 hours? :)

What I mean: If I go online at 00:04 the message will say: user x posted at July 05, 2013, 23:57:38

I know it was yesterday but it's only 7 minutes ago :)

Using SMF 2.0.4

Deaks

sorry on holiday atm will look at this when i get home
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

Biology Forums

Quote from: 4Three on July 05, 2013, 06:39:18 PM
Is there a way to include this for like 24 hours? :)

What I mean: If I go online at 00:04 the message will say: user x posted at July 05, 2013, 23:57:38

I know it was yesterday but it's only 7 minutes ago :)

Using SMF 2.0.4

I like this idea.

live627

Quote from: Runic on July 05, 2013, 06:46:33 PM
sorry on holiday atm will look at this when i get home

Maybe you also improve i18n handling with sprintf()'s instead of a literal text order.

Rain Forest

Quote from: Liam_michael on July 05, 2013, 10:40:04 PM
Quote from: 4Three on July 05, 2013, 06:39:18 PM
Is there a way to include this for like 24 hours? :)

What I mean: If I go online at 00:04 the message will say: user x posted at July 05, 2013, 23:57:38

I know it was yesterday but it's only 7 minutes ago :)

Using SMF 2.0.4

I like this idea.

I hope he can fix it :)

samborabora

Love this mod, but can we have it so that it has things like "about a month ago" and "about a a year ago" rather than defaulting to, say, June 12, 2014, 10:52:15 AM if there isn't anything within a recent timeframe? Or can I add this myself somehow?

Matthew K.

You could definitely add it yourself if you want...the idea is you don't need a relative timestamp if it's more than a day or so. A week is already a pretty big "about" timeframe. A month or a year is a long time. I'd rather have the timestamp at that point. You could modify the files and do it for yourself pretty easily.

Biology Forums

Quote from: Labradoodle-360 on June 13, 2014, 02:41:32 PM
You could definitely add it yourself if you want...the idea is you don't need a relative timestamp if it's more than a day or so. A week is already a pretty big "about" timeframe. A month or a year is a long time. I'd rather have the timestamp at that point. You could modify the files and do it for yourself pretty easily.

But how :P ?

live627

Quote from: samborabora on June 13, 2014, 02:37:20 PM
Love this mod, but can we have it so that it has things like "about a month ago" and "about a a year ago" rather than defaulting to, say, June 12, 2014, 10:52:15 AM if there isn't anything within a recent timeframe? Or can I add this myself somehow?
Complete rewrite needed.

samborabora

Quote from: live627 on June 13, 2014, 08:58:59 PM
Quote from: samborabora on June 13, 2014, 02:37:20 PM
Love this mod, but can we have it so that it has things like "about a month ago" and "about a a year ago" rather than defaulting to, say, June 12, 2014, 10:52:15 AM if there isn't anything within a recent timeframe? Or can I add this myself somehow?
Complete rewrite needed.

Aww, isn't it written so, say, a threshold time period can be assigned a new friendly time? What's the kinda structure the script uses so far that makes it impossible to just customize it? Is there another mod that does the same thing with more options?

Matthew K.

Quote from: samborabora on June 14, 2014, 07:46:14 AM
Quote from: live627 on June 13, 2014, 08:58:59 PM
Quote from: samborabora on June 13, 2014, 02:37:20 PM
Love this mod, but can we have it so that it has things like "about a month ago" and "about a a year ago" rather than defaulting to, say, June 12, 2014, 10:52:15 AM if there isn't anything within a recent timeframe? Or can I add this myself somehow?
Complete rewrite needed.

Aww, isn't it written so, say, a threshold time period can be assigned a new friendly time? What's the kinda structure the script uses so far that makes it impossible to just customize it? Is there another mod that does the same thing with more options?
I'd tend to believe the person who originally wrote the mod...

live627

Quote from: samborabora on June 14, 2014, 07:46:14 AM
Quote from: live627 on June 13, 2014, 08:58:59 PM
Quote from: samborabora on June 13, 2014, 02:37:20 PM
Love this mod, but can we have it so that it has things like "about a month ago" and "about a a year ago" rather than defaulting to, say, June 12, 2014, 10:52:15 AM if there isn't anything within a recent timeframe? Or can I add this myself somehow?
Complete rewrite needed.

Aww, isn't it written so, say, a threshold time period can be assigned a new friendly time? What's the kinda structure the script uses so far that makes it impossible to just customize it? Is there another mod that does the same thing with more options?
Only within the last 24 hours IIRC.

samborabora

Quote from: live627 on June 14, 2014, 08:00:35 PM
Quote from: samborabora on June 14, 2014, 07:46:14 AM
Quote from: live627 on June 13, 2014, 08:58:59 PM
Quote from: samborabora on June 13, 2014, 02:37:20 PM
Love this mod, but can we have it so that it has things like "about a month ago" and "about a a year ago" rather than defaulting to, say, June 12, 2014, 10:52:15 AM if there isn't anything within a recent timeframe? Or can I add this myself somehow?
Complete rewrite needed.

Aww, isn't it written so, say, a threshold time period can be assigned a new friendly time? What's the kinda structure the script uses so far that makes it impossible to just customize it? Is there another mod that does the same thing with more options?
Only within the last 24 hours IIRC.

And there's no other mod available that does this/the original author isn't planning on a rewrite?

vbgamer45

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Advertisement: