Firefox PHP

Module: Readable Dates and Concealed Times

Posted by Maurice Makaay 
All files from this thread

File Name File Size   Posted by Date  
readable_dates-1.2.1.zip 93.3 KB open | download Maurice Makaay 08/31/2016 Read message
Module: Readable Dates and Concealed Times
March 01, 2008 10:08AM
Make dates easier to read for humans, by using relative indications like "two hours ago", "yesterday, 12:30", "today, 17:52", "two weeks ago", "last year", etc.

Conceals message timestamp for messages older than 24 hours. Don't let your boss know that you wrote at work ...

All date indications can be customized through the language files.

Tested on version 5.2.20

This is a full rewrite of the Readable Dates module that was written for Phorum 5.1. Thanks to the new features in 5.2, I could get rid of some nasty constructions that were needed the 5.1 module.

Integration with other modules

Other modules or scripts that want to make use of the readable date formatting, can make use of a special hook call that is implemented by this module. If currently code like this is used for formatting:
    $date = phorum_date($PHORUM["short_date_time"], $time);
then it can be replaced with this:
  if (!empty($PHORUM['hooks']['format_readable_date'])) {
      $date = phorum_hook('format_readable_date', $time);
  } else {
      $date = phorum_date($PHORUM["short_date_time"], $time);
  }

Changelog:
----------

2016-08-31 version 1.2.1 by Oliver Riesen-Mallmann <oliver@riesen.org>

    - Made XHTML 1.0 Transitional compliant.

2016-07-27 version 1.2.0 by Oliver Riesen-Mallmann <oliver@riesen.org>

    - Module renamed to "Readable Dates and Concealed Times Module".

    - Functions of the "Conceal Message Timestamp Module" included. Formatting
      date and times in two separate modules didn't work well.

    - Fixed formatting for the announcement module.

    - README extended (license, module settings, language support, dependencies
      and GitHub link added).

    - Performance improvements.

    - Sanity checks added.

2015-09-18 v1.1.12 Oliver Riesen <oliver@riesen.org>

    - Fixed undefined index warning.

    - Performance improvements.

    - Added Greek language file. Thanks to Thanos.

2011-01-09 v1.1.11

    - Added new German language files. Thanks to Oliver Riesen!

2010-04-26 v1.1.10

    - The original dates are now available as $data['orig_<datefield>'], so
      they can still be accessed when needed from the templates.

2009-08-26 v1.1.9

    - Added support for the Russian language. Also added a Russian language
      file. Thanks to phorum.org user sailord for the translation!

    - Added a Spanish translation. Thanks to Chris Brown!

    - Added a French translation. Thanks to phorum.org user manuvb!

2008-12-14 v1.1.8

    - Fixed a typo that caused "date_last_active" for the user profile
      screen to never be formatted by this module.

2008-07-25 v1.1.7

    - Added a switch in the module config to enable/disable the formatting
      of the user registration date on the read pages (Registered: ... ago).
      If this switch is enabled, then dates after the configured time
      limit will be formatted using a standard short date. This is different
      from Phorum's default behavior, because by default Phorum would
      use a readable date-like formatting for this date already.

2008-05-28 v1.1.6

    - Another undefined index warning fixed and again it was CBiLL
      who was kind enough to be the lab rat.

2008-03-26 v1.1.5

    - Some more undefined index warnings fixed. These would occur if user
      activity tracking is disabled or if the user hides its activity
      through the privacy settings. Thanks to CBiLL for the report!

    - A configuration option was added to make it possible to disable
      the readable numbers (one, two, three instead of 1, 2, 3).

2008-03-11 v1.1.4

    - Fixes for some undefined index warnings in readable_dates.php.
      Thanks to CBiLL for the heads up!

2008-03-03 v1.1.3

    - Added support for formatting dates in the private message and buddy
      interfaces (pm list, pm read, buddy list). These features need Phorum
      version 5.2.7 or higher (the admin interface will warn about this if
      an older version of Phorum is used).

2008-03-02 v1.1.2

    - Added an option to specify the maximum time for which a date
      should be formatted by this module. Dates that are older will be
      displayed using their original formatting. Thanks to CBiLL for
      the feature suggestion.

    - Fixed a bug, which resulted in empty dates being formatted as
      if the date was Januari 1st, 1970 (Epoch zero). Thanks to
      CBiLL for the bug report.

2008-03-01 v1.1.1

    - Added a better German translation to the package. Thanks to Thomas
      for fixing my crappy German translation!

    - Fixed the formatting code to make sure that it will work
      correctly in localized environments.

2008-03-01 v1.1.0

    - Rewrote the module to be compatible with 5.2 and to make full
      use of new Phorum features.

2006-05-08 v1.0.7 and bofore

    - Stripped these change logs, as then don't have a relation to the new code anymore.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce



Edited 18 time(s). Last edit at 08/31/2016 09:32AM by Oliver Riesen-Mallmann.
Attachments:
open | download - readable_dates-1.2.1.zip (93.3 KB)
Re: Module: Readable Dates
March 01, 2008 12:18PM
Another nice module.

But your (or who's?) german translation has some errors

'seconds_ago_1'   => 'vor eine Sekunde',
'minutes_ago_1'   => 'vor eine Minute',
'hours_ago_1'     => 'vor eine Stunde',
'months_ago_0'    => 'diese Monat',
'months_ago_1'    => 'letzte Monat',

should be:

'seconds_ago_1'   => 'vor einer Sekunde',
'minutes_ago_1'   => 'vor einer Minute',
'hours_ago_1'     => 'vor einer Stunde',
'months_ago_0'    => 'diesen Monat',
'months_ago_1'    => 'letzten Monat',
Re: Module: Readable Dates
March 01, 2008 12:30PM
I did an attempt to translate it myself. Thomas is looking at the language file and fixing it for me as we speak^H^H^H^H^Htype. I'll release an updated package in a minute (1.1.1). That one also contains a few small fixes for the code, so get that one after my upload.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Module: Readable Dates
March 02, 2008 03:39AM
Module is great

But is it possible to make any post more than 12 hours old to have a normal date instead? It look kinda odd seeing 18 hours ago or 14 hours ago etc. I rather have the readable date only effect on anything that is less than 12 hours old and back to normal date if it more than 12 hour old.

It would be nice to have a setting like all / 12 / 24 / 48 etc all for all date and 12 for only on date up to 12 hours etc.

Btw on index in empty fourm will show 39 years hehe ...

Great job on the module!

Bill



Edited 1 time(s). Last edit at 03/02/2008 03:41AM by CBiLL.
Re: Module: Readable Dates
March 02, 2008 10:58AM
Give 1.1.2 a try CBiLL. I think that one fixes both your issues.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Module: Readable Dates
March 02, 2008 04:01PM
Quote
mmakaay
Give 1.1.2 a try CBiLL. I think that one fixes both your issues.


It fixed the empty forum bug and the new optional setting is perfect!

Thank you!
Bill
Re: Module: Readable Dates
March 02, 2008 08:15PM
I uploaded version 1.1.3. This version adds support for formatting dates in the private message and buddy interfaces (pm list, pm read, buddy list). These features need Phorum version 5.2.7 (not yet release at time of writing, but this one will probably be release in the next few days) or higher.

If you need the new formatting options now, then you will have to manually modify the pm.php script to add some new hooks that are required for this. If you want to do this, then please refer to changeset 3158 for the required changes.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Module: Readable Dates
March 11, 2008 11:25AM
I uploaded version 1.1.4, which fixes a few undefined index warnings in readable_dates.php. These warnings occurred when viewing the forum message list in threaded view and when requesting the RSS feed.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce



Edited 1 time(s). Last edit at 03/11/2008 12:27PM by mmakaay.
Re: Module: Readable Dates
March 25, 2008 04:23PM
This module are logging 2 more undefined index in event logger .. See pastebin link for logs [pastebin.com]

Bill
Re: Module: Readable Dates
March 26, 2008 04:29AM
I found the problem. In your case, this warning was shown for users that hide their activity in the privacy settings. The 1.1.5 version of the module fixes this problem. I also added an option to the configuration screen to be able to disable readable number formatting (i.e. replacing 1, 2, 3 with one, two, three).


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Sorry, only registered users may post in this forum.

Click here to login