Relative timestamps
This module aims to provide Facebook-like timestamps for Date fields from the Date module. As the supplied timestamp gets older, less accurate information will be shown.
The module differs from core's format_interval function in several aspects:
- e.g. if a timestamp is 1 hour 45 minutes older than the current time,
format_interval(with granularity set to 1) will return 1 hour. This module returns the more appropriate 2 hours.
e.g.2: 1 day + 3 hours ago and 1 day + 16 hours ago both return yesterday. - Future dates/timestamps are also supported. Instead of 'Time ago' the module will display 'in Time'.
- Support for the strings tomorrow and yesterday so they don't get any prefix ('in') of suffix ('ago').
- Date fields featuring start and end dates are supported. Core's
format_intervalonly displays the start date. Each case (past + past, past + future, ....) will get it's own constructed string.
Project page: http://drupal.org/sandbox/Propaganistas/1920568
Git: git clone --recursive --branch 7.x-1.0 http://git.drupal.org/sandbox/Propaganistas/1920568.git relative_timestamps
Earlier contributions: patch commits to ManyMail, many issue openings of bug reports.
Review bonus program:
http://drupal.org/node/1923524#comment-7094154
http://drupal.org/node/1924776#comment-7099088
http://drupal.org/node/1924326#comment-7099144
http://drupal.org/node/1912952#comment-7099228
http://drupal.org/node/1927104#comment-7108450
http://drupal.org/node/1825062#comment-7108518
Comments
Comment #1
abhijeetkalsi commentedHi,
first of all there are quite a few issues to sort out such as indentation, whitespace.
You can find them all here:
http://ventral.org/pareview/httpgitdrupalorgsandboxpropaganistas1920568git
Here you can check source code whether it meets drupal coding standards or not, and advise you what to change in your code. You can repeat review after your commits, and can fix those errors.
# Your first branch name can be 7.x-1.0, version comes after module released.
# Move your code repository to custom branch like 7.x-1.x, then delete master branch.
Comment #2
Anonymous (not verified) commentedHi AbhijeetKalsi
Thanks for your guidelines.
All warnings and errors have been fixed. PAReview now returns an empty report!
Please re-review the module.
Comment #2.0
Anonymous (not verified) commentedEnter project name as title
Comment #3
jbloomfield commentedNo errors through PARreview.
Nicely written module. I didn't find any major issues. It does what it says on the tin ;)
Comment #3.0
jbloomfield commented+ review bonus program
Comment #3.1
Anonymous (not verified) commentedReview bonus program nr2
Comment #4
Anonymous (not verified) commentedTagging
Comment #4.0
Anonymous (not verified) commentedReview bonus program nr3
Comment #5
DanaRoseRoss commentedI hate, hate, HATE coding this manually all the time, so thank you for a cool module. I've got a couple notes for you. Nothing too bad, but some things to think about:
Not sure if you should refer to this style of date as "Facebook style" in the .info file. Not everyone uses Facebook, and Facebook is going to fall out of style at some point and then that association does nothing for you. The rest of your description is fine without it.
In relative_timestamps_format(), you're define()-ing some values with pretty generic names (SECOND, MINUTE), and there's a chance those constants could collide with some other module or theme's definitions. Worse, someone else's code might be using those constants to hold strings instead of numbers, which would break your calculations. Instead of using define() there, how about switching to static variables? That way, your definitions still aren't going to get re-defined every time the function is called, but they're limited to the function's scope. For example:
should become
Comment #6
DanaRoseRoss commentedComment #7
Anonymous (not verified) commentedHi Dave
Thanks for the great suggestions. They definitely make sense so I incorporated them right away.
Setting this back to needs review.
Comment #8
klausiThank you for your reviews. When finishing your review comment also set the issue status either to "needs work" (you found some problems with the project) or "reviewed & tested by the community" (you found no major flaws).
manual review:
But otherwise looks RTBC to me. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.
Assigning to patrickd as he might have time to take a final look at this.
Comment #8.0
Anonymous (not verified) commentedReview bonus program nr.4
Comment #8.1
Anonymous (not verified) commentedextra PAReview
Comment #9
Anonymous (not verified) commentedThanks klausi for your review. Issues nr. 1 and 3 have been fixed.
Concerning nr. 2: the switch() is quite necessary actually, as this is the *first* and *only* check to whatever field display format has been chosen in the UI. The code in hook_field_formatter_view() has been greatly derived from the Date module.
Concerning nr. 4: I did explore the hook system hoping to find something pluggable to format for example the node posting time, but as you stated concisely: it turned out to be indeed a sad story.
Some more reviews done so re-tagging this.
Comment #10
patrickd commentedI'm a fan of nicely structured project pages with usage examples and screenshots!
But I'm not a fan of yours, yet ;-)
"relative_timestamps_worker" is an odd function name for what it does.. maybe "relative_timestamps_generate"?
but that's just nitpick..
I also quickly tested it on simplytest.me and everything seemed to work fine.
A small, solid module, ready to go..
Thanks for your contribution!
I updated your account to let you promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and get involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks to the dedicated reviewer(s) as well.
Comment #11
Anonymous (not verified) commentedThanks patrickd for your final suggestions!
Comment #12.0
(not verified) commentedextra PAReview