Closed (outdated)
Project:
Drupal core
Version:
7.x-dev
Component:
system.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
18 Jan 2011 at 07:08 UTC
Updated:
14 Feb 2014 at 20:38 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
bfroehle commentedAnd a patch.
Comment #2
jhodgdonThis patch references _system_date_formats_build(), but I can't find that function on api.drupal.org. Must be something wrong?
Comment #3
jhodgdonWhoops, that must have been a glitch on api.drupal.org.
The patch looks OK, except I don't think I'm familiar with doing
foreach ($types as $type => &$formats)Does that work?
Comment #4
jhodgdonAlso, $id is not really an "ID" per se, but the format's machine name. So I think for clarity it would be better to do:
Comment #5
bfroehle commentedI've taken jhodgdon's suggestion in #4 into account --- yes, using the fancy foreach value as reference is legal in PHP 5 --- but your suggestion adds to readability. I'm not too thrilled with
$name, as it's not a readable name in any sense but really more a$format. So I changed it toforeach ($formats as $format => $value) {?Also added some documentation about the contents of
$types, which was blatantly copied from _system_date_formats_build().Comment #6
jhodgdonThis looks pretty good. The only thing that seems a bit confusing in the text is that you say the secondary arrays are keyed by format, and then there is a format component just below. These are referring to two different things (format machine name vs. php date format), but that isn't clear from the text. I think the first reference should say "format machine name" instead of just "format"? Maybe for consistency, the outer array should reference machine name of the type also?
Also, I think the 5-letter codes are "locale" codes rather than "language" codes, and aren't the country portions capitalized, like en-US, en-CA, etc.?
Comment #7
bfroehle commentedTaking another stab at this. Changes:
$date_formats. This is consistent with the drupal_alter call in system.module.Not the prettiest, but I couldn't do better. :(
Comment #8
bfroehle commentedLol and now with proper PHP syntax. Doh!
Comment #9
jhodgdonThe @param section from the patch in #5 is missing from the patch in #8. I see that you did that intentionally, but you at least need to put in the @param and say something like "See xyz() for a description blah blah blah".
Comment #10
bfroehle commentedIs a simple "@see hook_date_formats()" line enough?
Comment #11
jhodgdonYou can't really put a @see inside a @param section, because @see makes a separate See Also section on api.drupal.org. So instead, write a short description of the parameter... something like:
Comment #12
tr commentedhook_date_formats_alter() no longer exists in Drupal 8, so moving this issue back to D7 which still has the problem.
Comment #13
jhodgdonHuh. I don't know what happened to it, as there is no change notice. Filed:
#2196557: hook_date_formats_alter() and related hooks removed, no searchable change notice!