diff --git a/modules/telvue_push/telvue_push.module b/modules/telvue_push/telvue_push.module index 7219742..a16c5e5 100644 --- a/modules/telvue_push/telvue_push.module +++ b/modules/telvue_push/telvue_push.module @@ -99,6 +99,7 @@ function telvue_push_get_mapping_targets() { 'label' => t('Location'), 'description' => t('32 characters or less'), ), + 'ingest_datetime' => array('label' => t('Ingest Datetime')), ); return $targets; @@ -409,6 +410,24 @@ function telvue_push_push($node, $return = TRUE) { $location = new SoapVar('', XSD_ANYXML); } + // INGEST Datetime + if (!empty($mapping['ingest_datetime']) && $mapped['ingest_datetime']) { + // Show time is typically formatted as '08/04/2015 - 8:00pm'. + $ingest_datetime = $mapped['ingest_datetime']; + $ingest_datetime = DateTime::createFromFormat ('m/d/Y - g:ia', $ingest_datetime); + + // Output format should be '2018-10-09 2:00 -04:00'. + $ingest_datetime = date_format($ingest_datetime, 'Y-m-d g:i P'); + + // Deal with badly formatted dates. + if ($ingest_datetime === FALSE) { + $ingest_datetime = date('Y-m-d g:i P', time()); + } + } + else { + $ingest_datetime = date('Y-m-d g:i P', time()); + } + // map other fields if (!empty($mapping['program']) && $mapped['program']) { $program_val = $mapped['program']; @@ -429,6 +448,7 @@ function telvue_push_push($node, $return = TRUE) { 'contributor' => $contributor , 'location' => $location, 'username' => $username, + 'ingest_datetime' => $ingest_datetime, ); ; diff --git a/telvue.module b/telvue.module index ae595a1..a076fb1 100644 --- a/telvue.module +++ b/telvue.module @@ -152,7 +152,9 @@ function telvue_addprogram($program, $server) { if (!isset($program['ingest_datetime'])) { $program['import_datetime'] = date('Y-m-d g:i P', time()); } - + else { + $program['import_datetime'] = $program['ingest_datetime']; + } if (!$program['expected_filename'] || !$program['expected_duration']) { return 'Failed';