[wp-trac] [WordPress Trac] #9272: Expand human_time_diff()'s abilities

WordPress Trac wp-trac at lists.automattic.com
Tue Jan 10 09:10:35 UTC 2012


#9272: Expand human_time_diff()'s abilities
-------------------------------------------------+-------------------------
 Reporter:  Viper007Bond                         |       Owner:
     Type:  enhancement                          |  Viper007Bond
 Priority:  normal                               |      Status:  new
Component:  Date/Time                            |   Milestone:  Future
 Severity:  normal                               |  Release
 Keywords:  has-patch needs-testing rtl-         |     Version:  2.8
  feedback                                       |  Resolution:
-------------------------------------------------+-------------------------

Comment (by westi):

 Replying to [comment:35 Viper007Bond]:
 > Replying to [comment:34 westi]:
 > > This gives us a simpler external API, a simpler handler function
 because it gets the labels to use passed in and they can live in the
 calling functions, an easy to extend function if you want to use it in
 another context.
 >
 > Can you explain your preference for having all of the code live in a
 helper function and `human_time_diff()` becoming a wrapper for it? Is it
 to avoid the legacy argument code at the top of my patch or something
 else?

 My preference is because as an end-user of these functions they are much
 more friendly and usable if I can just call them with one/two timestamps
 as arguments rather than having to wrap up and array of named arguments.

 {{{$args}}} as a single argument is really useful when you have lots of
 optional arguments but also makes it harder for less experience developers
 to use things and should be reserved for more "complex" functions than
 {{{human_time_diff()}}}.

 I don't think we should be using {{{$args}}} unless we have:
  * Many optional arguments which we expect 80%+ of callers to specify a
 least one of.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/9272#comment:36>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list