date.inc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. <?php
  2. /**
  3. * @file
  4. * Webform module date component.
  5. */
  6. /**
  7. * Implements _webform_defaults_component().
  8. */
  9. function _webform_defaults_date() {
  10. return array(
  11. 'name' => '',
  12. 'form_key' => NULL,
  13. 'pid' => 0,
  14. 'weight' => 0,
  15. 'value' => '',
  16. 'required' => 0,
  17. 'extra' => array(
  18. 'timezone' => 'user',
  19. 'exclude' => array(),
  20. 'start_date' => '-2 years',
  21. 'end_date' => '+2 years',
  22. 'year_textfield' => 0,
  23. 'datepicker' => 1,
  24. 'title_display' => 0,
  25. 'description' => '',
  26. 'description_above' => FALSE,
  27. 'private' => FALSE,
  28. 'analysis' => FALSE,
  29. ),
  30. );
  31. }
  32. /**
  33. * Implements _webform_theme_component().
  34. */
  35. function _webform_theme_date() {
  36. return array(
  37. 'webform_date' => array(
  38. 'render element' => 'element',
  39. 'file' => 'components/date.inc',
  40. ),
  41. 'webform_display_date' => array(
  42. 'render element' => 'element',
  43. 'file' => 'components/date.inc',
  44. ),
  45. 'webform_calendar' => array(
  46. 'variables' => array('component' => NULL, 'calendar_classes' => NULL),
  47. 'template' => 'templates/webform-calendar',
  48. ),
  49. );
  50. }
  51. /**
  52. * Implements _webform_edit_component().
  53. */
  54. function _webform_edit_date($component) {
  55. $form = array();
  56. $form['value'] = array(
  57. '#type' => 'textfield',
  58. '#title' => t('Default value'),
  59. '#default_value' => $component['value'],
  60. '#description' => t('The default value of the field.') . '<br />' . t('Accepts any date in any <a href="http://www.gnu.org/software/tar/manual/html_chapter/Date-input-formats.html">GNU Date Input Format</a>. Strings such as today, +2 months, and Dec 9 2004 are all valid.'),
  61. '#size' => 60,
  62. '#maxlength' => 127,
  63. '#weight' => 0,
  64. );
  65. $form['extra']['timezone'] = array(
  66. '#type' => 'radios',
  67. '#title' => t('Default value timezone'),
  68. '#default_value' => empty($component['extra']['timezone']) ? 'user' : $component['extra']['timezone'],
  69. '#description' => t('If using relative dates for a default value (for example, "today") base the current day on this timezone.'),
  70. '#options' => array('user' => t('User timezone'), 'site' => t('Website timezone')),
  71. '#weight' => 2,
  72. '#access' => variable_get('configurable_timezones', 1),
  73. );
  74. $form['extra']['exclude'] = array(
  75. '#type' => 'checkboxes',
  76. '#title' => t('Hide'),
  77. '#default_value' => $component['extra']['exclude'],
  78. '#options' => array(
  79. 'day' => t('Day'),
  80. 'month' => t('Month'),
  81. 'year' => t('Year'),
  82. ),
  83. '#description' => t('A hidden day or month will be set to 1. A hidden year will be set to the year of the default value.'),
  84. '#weight' => 3,
  85. );
  86. $form['display']['datepicker'] = array(
  87. '#type' => 'checkbox',
  88. '#title' => t('Enable popup calendar'),
  89. '#default_value' => $component['extra']['datepicker'],
  90. '#description' => t('Enable a JavaScript date picker next to the date field.'),
  91. '#weight' => 2,
  92. '#parents' => array('extra', 'datepicker'),
  93. );
  94. $form['display']['year_textfield'] = array(
  95. '#type' => 'checkbox',
  96. '#title' => t('Use a textfield for year'),
  97. '#default_value' => $component['extra']['year_textfield'],
  98. '#description' => t('If checked, the generated date field will use a textfield for the year. Otherwise it will use a select list.'),
  99. '#weight' => 5,
  100. '#parents' => array('extra', 'year_textfield'),
  101. );
  102. $form['validation']['start_date'] = array(
  103. '#type' => 'textfield',
  104. '#title' => t('Start date'),
  105. '#default_value' => $component['extra']['start_date'],
  106. '#description' => t('The earliest date that may be entered into the field.') . ' ' . t('Accepts any date in any <a href="http://www.gnu.org/software/tar/manual/html_chapter/Date-input-formats.html">GNU Date Input Format</a>.'),
  107. '#size' => 30,
  108. '#weight' => 3,
  109. '#parents' => array('extra', 'start_date'),
  110. );
  111. $form['validation']['end_date'] = array(
  112. '#type' => 'textfield',
  113. '#title' => t('End date'),
  114. '#default_value' => $component['extra']['end_date'],
  115. '#description' => t('The latest date that may be entered into the field.') . ' ' . t('Accepts any date in any <a href="http://www.gnu.org/software/tar/manual/html_chapter/Date-input-formats.html">GNU Date Input Format</a>.'),
  116. '#size' => 30,
  117. '#weight' => 4,
  118. '#parents' => array('extra', 'end_date'),
  119. );
  120. $form['#validate'] = array('_webform_edit_date_validate');
  121. return $form;
  122. }
  123. /**
  124. * Implements hook_form_id_validate().
  125. *
  126. * Warns user about hiding all the date fields and not using the date picker.
  127. */
  128. function _webform_edit_date_validate($form, &$form_state) {
  129. // Reduce checkbox values to simple non-associative array of values.
  130. form_set_value($form['extra']['exclude'], array_filter(array_values($form_state['values']['extra']['exclude'])), $form_state);
  131. // Note that Drupal 7 doesn't support setting errors no checkboxes due to
  132. // browser issues. See: https://www.drupal.org/node/222380
  133. if (count($form_state['values']['extra']['exclude']) == 3) {
  134. form_set_error('extra][exclude', 'The day, month and year can\'t all be hidden.');
  135. }
  136. if ($form_state['values']['extra']['exclude'] == array('month')) {
  137. form_set_error('extra][exclude', 'You cannot hide just the month.');
  138. }
  139. // Validate that the start and end dates are valid. Don't validate the default
  140. // date because with token substitution, it might not be valid at component
  141. // definition time. Also note that validation was introduced in 7.x-4.8 and
  142. // previously-defined webform may have invalid start and end dates.
  143. foreach (array('start_date', 'end_date') as $field) {
  144. if (trim($form_state['values']['extra'][$field]) && !($date[$field] = webform_strtodate('c', $form_state['values']['extra'][$field]))) {
  145. form_set_error("extra][$field", t('The @field could not be interpreted in <a href="http://www.gnu.org/software/tar/manual/html_chapter/Date-input-formats.html">GNU Date Input Format</a>.',
  146. array('@field' => $form['validation'][$field]['#title'])));
  147. }
  148. }
  149. if (!empty($date['start_date']) && !empty($date['end_date']) && $date['end_date'] < $date['start_date']) {
  150. form_set_error('extra][end_date', t('The End date must be on or after the Start date.'));
  151. }
  152. }
  153. /**
  154. * Implements _webform_render_component().
  155. */
  156. function _webform_render_date($component, $value = NULL, $filter = TRUE, $submission = NULL) {
  157. $node = isset($component['nid']) ? node_load($component['nid']) : NULL;
  158. $element = array(
  159. '#type' => 'date',
  160. '#title' => $filter ? webform_filter_xss($component['name']) : $component['name'],
  161. '#title_display' => $component['extra']['title_display'] ? $component['extra']['title_display'] : 'before',
  162. '#weight' => $component['weight'],
  163. '#description' => $filter ? webform_filter_descriptions($component['extra']['description'], $node) : $component['extra']['description'],
  164. '#required' => $component['required'],
  165. '#start_date' => trim($component['extra']['start_date']),
  166. '#end_date' => trim($component['extra']['end_date']),
  167. '#reference_timestamp' => $submission && $submission->completed ? $submission->completed : NULL,
  168. '#year_textfield' => $component['extra']['year_textfield'],
  169. '#default_value' => $filter ? webform_replace_tokens($component['value'], $node) : $component['value'],
  170. '#timezone' => $component['extra']['timezone'],
  171. '#exclude' => $component['extra']['exclude'],
  172. '#process' => array('webform_expand_date'),
  173. '#theme' => 'webform_date',
  174. '#theme_wrappers' => array('webform_element'),
  175. '#element_validate' => array('webform_validate_date'),
  176. '#translatable' => array('title', 'description'),
  177. );
  178. if ($component['extra']['datepicker']) {
  179. $element['#datepicker'] = TRUE;
  180. $element['#attached'] = array(
  181. 'library' => array(
  182. array('system', 'ui.datepicker'),
  183. ),
  184. );
  185. }
  186. // Set the value from Webform.
  187. if (isset($value[0]) && $value[0] !== '') {
  188. $value = webform_date_array($value[0], 'date');
  189. $element['#default_value'] = $value;
  190. }
  191. return $element;
  192. }
  193. /**
  194. * Form API #process function for Webform date fields.
  195. */
  196. function webform_expand_date($element) {
  197. $timezone = $element['#timezone'] != 'user' ? NULL : 'user';
  198. // Accept a string or array value for #default_value.
  199. if (!empty($element['#default_value']) && is_string($element['#default_value'])) {
  200. $timestring = webform_strtodate('c', $element['#default_value'], $timezone);
  201. $element['#default_value'] = webform_date_array($timestring, 'date');
  202. }
  203. // Prevent an error in PHP 5.4 caused by core's treatment of the #value.
  204. if (isset($element['#value'])) {
  205. unset($element['#value']);
  206. }
  207. // Set defaults according to existing #default_value (set by Form API).
  208. if (isset($element['#default_value']['month']) || isset($element['#default_value']['day']) || isset($element['#default_value']['year'])) {
  209. $default_values = array(
  210. 'month' => $element['#default_value']['month'],
  211. 'day' => $element['#default_value']['day'],
  212. 'year' => $element['#default_value']['year'],
  213. );
  214. }
  215. else {
  216. $default_values = array(
  217. 'day' => NULL,
  218. 'month' => NULL,
  219. 'year' => NULL,
  220. );
  221. }
  222. // Let Drupal do it's normal expansion.
  223. $element = form_process_date($element);
  224. // Convert relative dates to absolute and calculate the year, month and day.
  225. $timezone = $element['#timezone'] != 'user' ? NULL : 'user';
  226. foreach (array('start', 'end') as $start_end) {
  227. $element_field = &$element["#{$start_end}_date"];
  228. $element_field = $element_field ? webform_strtodate('Y-m-d', $element_field, $timezone, $element['#reference_timestamp']) : '';
  229. if ($element_field) {
  230. $parts = explode('-', $element_field);
  231. }
  232. else {
  233. $parts = $start_end == 'start' ? array(webform_strtodate('Y', '-2 years'), 1, 1) : array(webform_strtodate('Y', '+2 years'), 12, 31);
  234. $element_field = '';
  235. }
  236. // Drop PHP reference.
  237. unset($element_field);
  238. $parts[3] = $parts[0] . '-' . $parts[1] . '-' . $parts[2];
  239. $range[$start_end] = array_combine(array('year', 'month', 'day', 'date'), $parts);
  240. }
  241. // The start date is not guaranteed to be early than the end date for
  242. // historical reasons.
  243. if ($range['start']['date'] > $range['end']['date']) {
  244. $temp = $range['start'];
  245. $range['start'] = $range['end'];
  246. $range['end'] = $temp;
  247. }
  248. // Restrict the months and days when not all options are valid choices.
  249. if ($element['#start_date'] && $element['#end_date']) {
  250. $delta_months = ($range['end']['year'] * 12 + $range['end']['month']) - ($range['start']['year'] * 12 + $range['start']['month']);
  251. if ($delta_months < 11) {
  252. // There are 10 or fewer months between the start and end date. If there
  253. // were 11, then every month would be possible, and the menu select
  254. // should not be pruned.
  255. $month_options = &$element['month']['#options'];
  256. if ($range['start']['month'] <= $range['end']['month']) {
  257. $month_options = array_intersect_key($month_options, array_flip(range($range['start']['month'], $range['end']['month'])));
  258. }
  259. else {
  260. $month_options = array_intersect_key($month_options, array_flip(range($range['start']['month'], 12))) +
  261. array_intersect_key($month_options, array_flip(range(1, $range['end']['month'])));
  262. }
  263. // Drop PHP reference.
  264. unset($month_options);
  265. if ($delta_months <= 1) {
  266. // The start and end date are either on the same month or consecutive
  267. // months. See if the days should be pruned.
  268. $day_options = &$element['day']['#options'];
  269. if ($range['start']['month'] == $range['end']['month']) {
  270. // Range is within the same month. The days are a simple range from
  271. // start day to end day.
  272. $day_options = array_intersect_key($day_options, array_flip(range($range['start']['day'], $range['end']['day'])));
  273. }
  274. elseif ($range['start']['day'] > $range['end']['day'] + 1) {
  275. // Range spans two months and at least one day would be omitted.
  276. $days_in_month = date('t', mktime(0, 0, 0, $range['start']['month'], 1, $range['start']['year']));
  277. $day_options = array_intersect_key($day_options, array_flip(range($range['start']['day'], $days_in_month))) +
  278. array_intersect_key($day_options, array_flip(range(1, $range['end']['day'])));
  279. }
  280. // Drop PHP reference.
  281. unset($day_options);
  282. }
  283. }
  284. }
  285. // Set default values.
  286. foreach ($default_values as $type => $value) {
  287. switch ($type) {
  288. case 'month':
  289. $none = t('Month');
  290. $hidden_default = 1;
  291. break;
  292. case 'day':
  293. $none = t('Day');
  294. $hidden_default = 1;
  295. break;
  296. case 'year':
  297. $none = t('Year');
  298. $hidden_default = !empty($element['#default_value']['year']) ? $element['#default_value']['year'] : webform_strtodate('Y', 'today', $timezone);
  299. break;
  300. }
  301. unset($element[$type]['#value']);
  302. $element[$type]['#title'] = $none;
  303. $element[$type]['#title_display'] = 'invisible';
  304. $element[$type]['#default_value'] = $default_values[$type];
  305. $element[$type]['#options'] = array('' => $none) + $element[$type]['#options'];
  306. if (in_array($type, $element['#exclude'])) {
  307. $element[$type] += array(
  308. '#prefix' => '<div class="webform-date-field-wrapper element-invisible">',
  309. '#suffix' => '</div>',
  310. );
  311. $element[$type]['#default_value'] = $hidden_default;
  312. }
  313. }
  314. // Tweak the year field.
  315. if ($element['#year_textfield']) {
  316. $element['year']['#type'] = 'textfield';
  317. $element['year']['#size'] = 5;
  318. $element['year']['#maxlength'] = 4;
  319. unset($element['year']['#options']);
  320. }
  321. elseif ($element['#start_date'] || $element['#end_date']) {
  322. $element['year']['#options'] = array('' => t('Year')) + drupal_map_assoc(range($range['start']['year'], $range['end']['year']));
  323. }
  324. return $element;
  325. }
  326. /**
  327. * Theme a webform date element.
  328. */
  329. function theme_webform_date($variables) {
  330. $element = $variables['element'];
  331. $element['year']['#attributes']['class'][] = 'year';
  332. $element['month']['#attributes']['class'][] = 'month';
  333. $element['day']['#attributes']['class'][] = 'day';
  334. // Add error classes to all items within the element.
  335. if (form_get_error($element)) {
  336. $element['year']['#attributes']['class'][] = 'error';
  337. $element['month']['#attributes']['class'][] = 'error';
  338. $element['day']['#attributes']['class'][] = 'error';
  339. }
  340. // Add HTML5 required attribute, if needed.
  341. if ($element['#required']) {
  342. $element['year']['#attributes']['required'] = 'required';
  343. $element['month']['#attributes']['required'] = 'required';
  344. $element['day']['#attributes']['required'] = 'required';
  345. }
  346. $class = array('webform-container-inline');
  347. // Add the JavaScript calendar if available (provided by Date module package).
  348. if (!empty($element['#datepicker'])) {
  349. $class[] = 'webform-datepicker';
  350. $calendar_class = array('webform-calendar');
  351. if ($element['#start_date']) {
  352. $calendar_class[] = 'webform-calendar-start-' . $element['#start_date'];
  353. }
  354. if ($element['#end_date']) {
  355. $calendar_class[] = 'webform-calendar-end-' . $element['#end_date'];
  356. }
  357. $calendar_class[] = 'webform-calendar-day-' . variable_get('date_first_day', 0);
  358. $calendar = theme('webform_calendar', array('component' => $element['#webform_component'], 'calendar_classes' => $calendar_class));
  359. }
  360. $output = '';
  361. $output .= '<div class="' . implode(' ', $class) . '">';
  362. $output .= drupal_render_children($element);
  363. $output .= isset($calendar) ? $calendar : '';
  364. $output .= '</div>';
  365. return $output;
  366. }
  367. /**
  368. * Element validation for Webform date fields.
  369. */
  370. function webform_validate_date($element, $form_state) {
  371. $date_parts = array('day', 'month', 'year');
  372. // Determine if the user has specified a date. Hidden parts of the date will
  373. // be submitted automatically.
  374. foreach ($date_parts as $date_part) {
  375. if (!in_array($date_part, $element['#exclude']) && $element[$date_part]['#value'] !== '') {
  376. $field_found = TRUE;
  377. }
  378. }
  379. if (isset($field_found)) {
  380. // Check that each part of the date has been filled in.
  381. foreach ($date_parts as $date_part) {
  382. if (empty($element[$date_part]['#value'])) {
  383. form_error($element[$date_part], t('!part in !name is missing.', array('!name' => $element['#title'], '!part' => $element[$date_part]['#title'])));
  384. $missing_fields = TRUE;
  385. }
  386. }
  387. if (isset($missing_fields)) {
  388. return;
  389. }
  390. // Ensure date is made up of integers.
  391. foreach ($date_parts as $date_part) {
  392. $element[$date_part]['#value'] = (int) $element[$date_part]['#value'];
  393. }
  394. // Check for a valid date.
  395. if (!checkdate($element['month']['#value'], $element['day']['#value'], $element['year']['#value'])) {
  396. form_error($element, t('Entered !name is not a valid date.', array('!name' => $element['#title'])));
  397. return;
  398. }
  399. // Create a timestamp of the entered value for comparison.
  400. $timestamp = strtotime($element['year']['#value'] . '-' . $element['month']['#value'] . '-' . $element['day']['#value']);
  401. $format = webform_date_format('short');
  402. // Flip start and end if needed. Prior to 7.x-4.8, it was possible to save
  403. // a date component with the end date earlier than the start date.
  404. $date1 = strtotime($element['#start_date']);
  405. $date2 = strtotime($element['#end_date']);
  406. if ($date1 !== FALSE && $date2 !== FALSE) {
  407. $start_date = $date1 < $date2 ? $date1 : $date2;
  408. $end_date = $date1 > $date2 ? $date1 : $date2;
  409. }
  410. else {
  411. $start_date = $date1;
  412. $end_date = $date2;
  413. }
  414. // Check that the date is after the start date.
  415. if ($start_date !== FALSE && $timestamp < $start_date) {
  416. form_error($element, t('The entered date must be @start_date or later.', array('@start_date' => date($format, $start_date))));
  417. }
  418. // Check that the date is before the end date.
  419. if ($end_date !== FALSE && $timestamp > $end_date) {
  420. form_error($element, t('The entered date must be @end_date or earlier.', array('@end_date' => date($format, $end_date))));
  421. }
  422. }
  423. elseif ($element['#required']) {
  424. form_error($element, t('!name field is required.', array('!name' => $element['#title'])));
  425. }
  426. }
  427. /**
  428. * Implements _webform_submit_component().
  429. */
  430. function _webform_submit_date($component, $value) {
  431. // Convert the date to an ISO 8601 format.
  432. return ($value['year'] && $value['month'] && $value['day']) ? webform_date_string($value, 'date') : '';
  433. }
  434. /**
  435. * Implements _webform_display_component().
  436. */
  437. function _webform_display_date($component, $value, $format = 'html', $submission = array()) {
  438. $value = webform_date_array(isset($value[0]) ? $value[0] : '', 'date');
  439. return array(
  440. '#title' => $component['name'],
  441. '#title_display' => $component['extra']['title_display'] ? $component['extra']['title_display'] : 'before',
  442. '#weight' => $component['weight'],
  443. '#theme' => 'webform_display_date',
  444. '#theme_wrappers' => $format == 'html' ? array('webform_element') : array('webform_element_text'),
  445. '#format' => $format,
  446. '#exclude' => $component['extra']['exclude'],
  447. '#value' => $value,
  448. '#translatable' => array('title'),
  449. );
  450. }
  451. /**
  452. * Format the text output for this component.
  453. */
  454. function theme_webform_display_date($variables) {
  455. $element = $variables['element'];
  456. $output = ' ';
  457. if ($element['#value']['year'] && $element['#value']['month'] && $element['#value']['day']) {
  458. $timestamp = webform_strtotime($element['#value']['month'] . '/' . $element['#value']['day'] . '/' . $element['#value']['year']);
  459. $format = webform_date_format(NULL, $element['#exclude']);
  460. $output = format_date($timestamp, 'custom', $format, 'UTC');
  461. }
  462. return $output;
  463. }
  464. /**
  465. * Implements _webform_analysis_component().
  466. */
  467. function _webform_analysis_date($component, $sids = array(), $single = FALSE, $join = NULL) {
  468. $query = db_select('webform_submitted_data', 'wsd', array('fetch' => PDO::FETCH_ASSOC))
  469. ->fields('wsd', array('no', 'data'))
  470. ->condition('wsd.nid', $component['nid'])
  471. ->condition('wsd.cid', $component['cid'])
  472. ->orderBy('wsd.sid');
  473. if (count($sids)) {
  474. $query->condition('wsd.sid', $sids, 'IN');
  475. }
  476. if ($join) {
  477. $query->innerJoin($join, 'ws2_', 'wsd.sid = ws2_.sid');
  478. }
  479. $result = $query->execute();
  480. $dates = array();
  481. $submissions = 0;
  482. foreach ($result as $row) {
  483. $submissions++;
  484. if ($row['data']) {
  485. $dates[] = webform_date_array($row['data']);
  486. }
  487. }
  488. // Display stats.
  489. $nonblanks = count($dates);
  490. $rows[0] = array(t('Left Blank'), ($submissions - $nonblanks));
  491. $rows[1] = array(t('User entered value'), $nonblanks);
  492. return array(
  493. 'table_rows' => $rows,
  494. );
  495. }
  496. /**
  497. * Implements _webform_table_component().
  498. */
  499. function _webform_table_date($component, $value) {
  500. if ($value[0]) {
  501. $timestamp = webform_strtotime($value[0]);
  502. $format = webform_date_format('short', $component['extra']['exclude']);
  503. return format_date($timestamp, 'custom', $format, 'UTC');
  504. }
  505. else {
  506. return '';
  507. }
  508. }
  509. /**
  510. * Implements _webform_csv_headers_component().
  511. */
  512. function _webform_csv_headers_date($component, $export_options) {
  513. $header = array();
  514. $header[0] = '';
  515. $header[1] = '';
  516. $header[2] = $export_options['header_keys'] ? $component['form_key'] : $component['name'];
  517. return $header;
  518. }
  519. /**
  520. * Implements _webform_csv_data_component().
  521. */
  522. function _webform_csv_data_date($component, $export_options, $value) {
  523. if ($value[0]) {
  524. $timestamp = webform_strtotime($value[0]);
  525. if (!empty($export_options['iso8601_date'])) {
  526. // ISO 8601 date: 2004-02-12.
  527. $format = 'Y-m-d';
  528. }
  529. else {
  530. $format = webform_date_format('short');
  531. }
  532. return format_date($timestamp, 'custom', $format, 'UTC');
  533. }
  534. else {
  535. return '';
  536. }
  537. }