Use case: A nodes change date may be printed in date format 'medium'.
Problem: return value of WdNodeWrapper->getChangedTime('medium') is empty.
Workaround: set an empty string as argument $custom_format to the method call: WdNodeWrapper->getChangedTime('medium', '')

Analysis:

WdNodeWrapper->getChangedTime() and WdEntityWrapper->getDate() have their third argument ($custom_format) set to NULL by default.
Unfortunately Drupals function form_data - which is used by WdEntityWrapper->getDate() - checks (when the date type is 'medium') whether the $custom_format is an _empty string_ (not NULL!):

common.inc, at line 2030 (Drupal 7.37):

      [...]
      // Fall back to 'medium'.
      if ($format === '') {
        $format = variable_get('date_format_medium', 'D, m/d/Y - H:i');
      }
      [...]

Possible fix: Set the default value of the arguments $custom_format to '' instead of NULL.

Comments

  • zengenuity committed ada963e on 7.x-1.x
    Issue #2495727: getDate() functions don't build 'medium' date formats...

  • zengenuity committed d18989d on 7.x-1.x
    Issue #2495727: getDate() functions don't build 'medium' date formats...
zengenuity’s picture

Status: Active » Fixed

You're right. Thanks for digging into it to find out the cause.

I've fixed this in 7.x-1.x-dev.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.