Advertisement:

Author Topic: Relative Dates  (Read 32798 times)

Offline ocmdiaz714

  • Jr. Member
  • **
  • Posts: 202
Re: Relative Dates
« Reply #40 on: August 23, 2012, 04:10:26 PM »
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:

Code: [Select]
// 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.
« Last Edit: August 24, 2012, 12:24:48 AM by ocmdiaz714 »

Offline ocmdiaz714

  • Jr. Member
  • **
  • Posts: 202
Re: Relative Dates
« Reply #41 on: September 01, 2012, 06:18:45 AM »
Any update?

Offline Rain Forest

  • Full Member
  • ***
  • Posts: 657
  • 𝒢𝒾𝓇𝒶𝒻𝒻𝑒
    • Love Troops
Re: Relative Dates
« Reply #42 on: September 01, 2012, 02:31:53 PM »
Thank you! Im using this mod right now :)

Offline ocmdiaz714

  • Jr. Member
  • **
  • Posts: 202
Re: Relative Dates
« Reply #43 on: September 01, 2012, 04:41:41 PM »
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?

Offline Biology Forums

  • SMF Hero
  • ******
  • Posts: 3,778
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Re: Relative Dates
« Reply #44 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?

TheListener

  • Guest
Re: Relative Dates
« Reply #45 on: June 08, 2013, 07:21:30 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.

Offline Rain Forest

  • Full Member
  • ***
  • Posts: 657
  • 𝒢𝒾𝓇𝒶𝒻𝒻𝑒
    • Love Troops
Re: Relative Dates
« Reply #46 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

Offline Deaks

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 22,544
  • Gender: Male
    • trekkiesforyes on Facebook
    • pouvik on GitHub
    • @trekkies4yes on Twitter
    • YES
Re: Relative Dates
« Reply #47 on: July 05, 2013, 06:46:33 PM »
sorry on holiday atm will look at this when i get home

Offline Biology Forums

  • SMF Hero
  • ******
  • Posts: 3,778
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Re: Relative Dates
« Reply #48 on: July 05, 2013, 10:40:04 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.

Offline live627

  • Developer
  • SMF Hero
  • *
  • Posts: 5,918
  • Gender: Male
    • live627 on Facebook
    • live627 on GitHub
    • live627 on LinkedIn
    • @live627 on Twitter
    • livemods
Re: Relative Dates
« Reply #49 on: July 06, 2013, 12:41:34 AM »
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.

Offline Rain Forest

  • Full Member
  • ***
  • Posts: 657
  • 𝒢𝒾𝓇𝒶𝒻𝒻𝑒
    • Love Troops
Re: Relative Dates
« Reply #50 on: September 11, 2013, 06:19:32 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 :)

Offline samborabora

  • Full Member
  • ***
  • Posts: 517
Re: Relative Dates
« Reply #51 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?

Offline Matthew K.

  • SMF Super Hero
  • *******
  • Posts: 12,431
  • Gender: Male
    • matthew.kerle on Facebook
    • @matthew_kerle on Twitter
Re: Relative Dates
« Reply #52 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.

Offline Biology Forums

  • SMF Hero
  • ******
  • Posts: 3,778
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Re: Relative Dates
« Reply #53 on: June 13, 2014, 06:05:46 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 ?

Offline live627

  • Developer
  • SMF Hero
  • *
  • Posts: 5,918
  • Gender: Male
    • live627 on Facebook
    • live627 on GitHub
    • live627 on LinkedIn
    • @live627 on Twitter
    • livemods
Re: Relative Dates
« Reply #54 on: June 13, 2014, 08:58:59 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.

Offline samborabora

  • Full Member
  • ***
  • Posts: 517
Re: Relative Dates
« Reply #55 on: June 14, 2014, 07:46:14 AM »
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?

Offline Matthew K.

  • SMF Super Hero
  • *******
  • Posts: 12,431
  • Gender: Male
    • matthew.kerle on Facebook
    • @matthew_kerle on Twitter
Re: Relative Dates
« Reply #56 on: June 14, 2014, 11:35:12 AM »
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...

Offline live627

  • Developer
  • SMF Hero
  • *
  • Posts: 5,918
  • Gender: Male
    • live627 on Facebook
    • live627 on GitHub
    • live627 on LinkedIn
    • @live627 on Twitter
    • livemods
Re: Relative Dates
« Reply #57 on: June 14, 2014, 08:00:35 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.

Offline samborabora

  • Full Member
  • ***
  • Posts: 517
Re: Relative Dates
« Reply #58 on: June 15, 2014, 10:52:14 AM »
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?

Offline vbgamer45

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 23,475
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Relative Dates
« Reply #59 on: June 15, 2014, 01:08:32 PM »
No rewrite planned.
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