Needs work
Project:
Timeago
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
1 Aug 2013 at 02:26 UTC
Updated:
21 Jan 2022 at 11:42 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
angrytoast commentedPatch attached:
Comment #2
icecreamyou commentedWhat are these cases?
Why does that happen?
Is that the expected behavior for the Timeago library?
This sounds like something that should be fixed either server-side or in the Timeago library itself (or both).
Comment #3
narkoff commentedI was having a very similar issue where I was getting duplicate timeago dates when the Views formatter was set to 'Date and time' and selecting a custom timeago date format.
Conversely, timeago worked properly (returning single dates) if I select the 'Timeago' formatter in Views. However, this formatter would not work for future dates. The returned date was '0 sec'. I could only get future dates to work using the' Date and time' formatter.
This patch solved the duplicate dates issue using the 'Date and time' formatter. Thanks!
Comment #4
fau commentedThere is a problem with "Date and time" formatter from Date API. What it does is it limits our custom date format to date, time and timezone, and then formats them individually (see date.module: date_formatter_process). Later they get reused in various contexts.
For example a date field with display "start and end date" gets rendered like this:
$start_formatted . ' - ' . $end_formatted_time . ' ' $end_formatted_timezoneand the output isThursday, April 9, 2015 - 19:00 CEST to 21:00 CEST. (see date.theme: theme_date_display_combination)Unfortunately each of these variables gets formatted separately, so we end up with three class="timeago" html wrappers.
If our date format doesn't have timezone format characters, $end_formatted_timezone won't be rendered only if all custom characters (besides punctuation) in date format are escaped, like this:
Long:
\<\s\p\a\n \c\l\a\s\s\=\\\"\t\i\m\e\a\g\o\\\" \t\i\t\l\e\=\\\"c"\>l, j F Y - H:i\<\/\s\p\a\n\>Medium:
\<\s\p\a\n \c\l\a\s\s\=\\\"\t\i\m\e\a\g\o\\\" \t\i\t\l\e\=\\\"c"\>D, d/m/Y - H:i\<\/\s\p\a\n\>Short:
\<\s\p\a\n \c\l\a\s\s\=\\\"\t\i\m\e\a\g\o\\\" \t\i\t\l\e\=\\\"c"\>d/m/Y - H:i\<\/\s\p\a\n\>These also work with php date() function and could replace module's defaults.
Notice that last " character must be unescaped. I think this is due to a bug in date_limit_format (but I don't understand their preg_replace pattern).
Of course "Start and end date" display will still output rubbish with timeago date type, so the resolution of this bug should be that "Date and time" formatter isn't supported. However with the aforementioned date format strings you can use timeago with it when there is only a single date displayed. Original patch gets the job done too.
Comment #5
kopeboyI think you have put too many escapes.
This worked for me:
\<\s\p\a\n \c\l\a\s\s\=\"\t\i\m\e\a\g\o\" \t\i\t\l\e\=\"c"\>l, j F Y - H:i\<\/\s\p\a\n\>So the steps to do to make timeago work, without patches as of now, with "Date and time" format for a field (in Manage Display or a View) are:
I, j F Y - U:ipart) and saveI think you could rewrite the module provided formats to use the escaped notation so they would still work out of the box if a site has Date module installed (half a million at least...)
Comment #6
kopeboyAfter 6 years the problem is still present:
enabling this module and using any provded date type, will crash the admin manage display of every date field with format Date and time
Please fix them.
Comment #7
atul4drupal commented