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

WordPress Trac wp-trac at lists.automattic.com
Wed Jan 4 22:31:23 UTC 2012


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

Comment (by dd32):

 If i was doing this, i'd have:
 {{{
 human_time_diff( $args ) {
   if ( ! is_array($args ) {
     $args = array();
     list($args['from'], $args['to']) = func_get_args();
   }
   $defaults = array('from' => null, 'to' => time(), 'labels' => ....
   ...
 }

 human_time_diff_ago($args) {
   $args['labels']['months'] = array( '%s month ago', '%s months ago' );
   ...
 }
 human_time_diff_until($args) {
   $args['labels']['months'] = array( 'in %s month', 'in %s months' );
   ...
 }
 human_time_diff_age($args) {
   $args['labels']['months'] = array( '%s month old', '%s months old' );
   ...
 }
 }}}

 of course, that would still have the problem of 'slotting' a translated
 string into another string, not exactly ideal. Other chances that
 age|until|ago doesn't cover everything either that it'd be used in.

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


More information about the wp-trac mailing list