Commit fe425d71 authored by Damien McKenna's avatar Damien McKenna Committed by Damien McKenna
Browse files

Issue #3306819 by DamienMcKenna: dc:date uses wrong format.

parent 1a4b427d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ Views RSS 8.x-2.x-dev, 2022-xx-xx
#3305462 by DamienMcKenna: Test coverage for the channel output.
#3306603 by DamienMcKenna: Test coverage for channel link.
#3306799 by DamienMcKenna: Pubdate values use the wrong format.
#3306819 by DamienMcKenna: dc:date uses wrong format.


Views RSS 8.x-2.0-rc1, 2022-04-29
+17 −0
Original line number Diff line number Diff line
@@ -50,6 +50,9 @@ function views_rss_dc_views_rss_item_elements() {
    'description' => t('A date associated with an event in the life cycle of the resource. Typically, Date will be associated with the creation or availability of the resource.  Recommended best practice for encoding the date value is defined in a profile of <a href="@formats_url">ISO 8601</a> and follows the YYYY-MM-DD format.', [
      '@formats_url' => 'http://www.w3.org/TR/NOTE-datetime',
    ]),
    'preprocess functions' => [
      'views_rss_dc_preprocess_item_dc_date',
    ],
    'help' => 'http://dublincore.org/documents/1999/07/02/dces/#date',
  ];
  $elements['dc:type'] = [
@@ -123,3 +126,17 @@ function views_rss_dc_preprocess_item_dc_creator(&$variables) {

  $variables['elements'] = $elements;
}

/**
 * Preprocess function for item <dc:date> element.
 *
 * Converts dates to ISO-8601 format, per the specifications.
 *
 * @see https://www.dublincore.org/specifications/dublin-core/dcmi-terms/terms/date/
 */
function views_rss_dc_preprocess_item_dc_date(&$variables) {
  if (empty($variables['elements'][0]['value'])) {
    return;
  }
  $variables['elements'][0]['value'] = date('c', strtotime((string) $variables['elements'][0]['value']));
}