Time_ago module + hack
Posted by alfaguru
All files from this thread
File Name | File Size | Posted by | Date | ||
---|---|---|---|---|---|
time_ago.zip | 1.3 KB | open | download | alfaguru | 01/08/2007 | Read message |
Time_ago module + hack January 08, 2007 02:10PM |
Registered: 17 years ago Posts: 7 |
Hi, I've written a little module which changes the display of timestamps to the form 'X units ago' ('5 seconds ago', '1 hour ago', etc.), which I think is generally a friendlier way to display them. It needs the following hack to work:
after
insert
after
function phorum_date( $picture, $ts ) {in format_functions.php
insert
if(defined('PHORUM_MOD_TIME_AGO')) { return phorum_time_ago($ts); }The attached module contains the rest of the code, which is pretty straightforward if not exactly elegant.
Re: Time_ago module + hack January 08, 2007 02:13PM |
Registered: 22 years ago Posts: 1,076 |
Re: Time_ago module + hack January 08, 2007 02:20PM |
Registered: 17 years ago Posts: 7 |
Do you mean the readable_dates module? It doesn't do the same thing as this.
The reason this is a hack and not a module is because I couldn't find a way to get at dates on a page in their original timestamp form rather than as formatted strings. The readable_dates module performs some contortions to force dates to be formatted in a way it can parse back. I didn't really want to do that as it creates so many possibilities for bugs when dealing with the unformatted timestamps is so much simpler.
The reason this is a hack and not a module is because I couldn't find a way to get at dates on a page in their original timestamp form rather than as formatted strings. The readable_dates module performs some contortions to force dates to be formatted in a way it can parse back. I didn't really want to do that as it creates so many possibilities for bugs when dealing with the unformatted timestamps is so much simpler.
Re: Time_ago module + hack January 08, 2007 03:03PM |
Admin Registered: 19 years ago Posts: 8,532 |
This type of displaying of relative dates is something that I have planned to integrate in readable_dates as well. But that will only be done for Phorum 5.2. Two reasons for only implementing it in 5.2 are:
* Phorum 5.2 already has some code built in for formatting relative dates (currently used for telling how long ago a user registered in the profile);
* I want to make some changes to the data structures so modules can access the unformatted datestamps. That will make this kind of module a lot easier and cleaner to write in 5.2.
So till 5.2, this module will be great for people who want relative date formatting. Thanks for writing the mod!
Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
* Phorum 5.2 already has some code built in for formatting relative dates (currently used for telling how long ago a user registered in the profile);
* I want to make some changes to the data structures so modules can access the unformatted datestamps. That will make this kind of module a lot easier and cleaner to write in 5.2.
So till 5.2, this module will be great for people who want relative date formatting. Thanks for writing the mod!
Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Time_ago module + hack January 08, 2007 04:23PM |
Registered: 22 years ago Posts: 1,076 |
Quote
alfaguru
Do you mean the readable_dates module? It doesn't do the same thing as this.
Sorry yes, I remebered it wrong.
Quote
alfaguru
The reason this is a hack and not a module is because I couldn't find a way to get at dates on a page in their original timestamp form rather than as formatted strings. The
Yeah, I checked and there's no hook after the messages are fetched from db. If there was a hook right after db fetch the date wouldn't be contaminated yet and would make for example date mods much easier.
---
-=[ Panu ]=-
Sorry, only registered users may post in this forum.