From cdc5ffafad6be5c449a2f00b3be6a7fbb957a02e Mon Sep 17 00:00:00 2001 From: Jeremy Lichtman Date: Wed, 3 Oct 2018 17:40:19 -0400 Subject: [PATCH 1/3] ZD-279: Allow ingest datetime to be mapped. --- modules/telvue_push/telvue_push.module | 12 ++++++++++++ telvue.module | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/telvue_push/telvue_push.module b/modules/telvue_push/telvue_push.module index 7219742..a2d8c01 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,16 @@ function telvue_push_push($node, $return = TRUE) { $location = new SoapVar('', XSD_ANYXML); } + // INGEST Datetime + if (!empty($mapping['ingest_datetime']) && $mapped['ingest_datetime']) { + $ingest_datetime = $mapped['ingest_datetime']; + $ingest_datetime = strtotime($ingest_datetime); + $ingest_datetime = date('Y-m-d g:i P', $ingest_datetime); + } + 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 +440,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'; From b95b4d43bf9efaf9a34dfa31f5f01b88d546f753 Mon Sep 17 00:00:00 2001 From: Jeremy Lichtman Date: Tue, 9 Oct 2018 14:12:03 -0400 Subject: [PATCH 2/3] ZD-279: Fix date format. --- modules/telvue_push/telvue_push.module | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/telvue_push/telvue_push.module b/modules/telvue_push/telvue_push.module index a2d8c01..d504a3d 100644 --- a/modules/telvue_push/telvue_push.module +++ b/modules/telvue_push/telvue_push.module @@ -412,9 +412,17 @@ function telvue_push_push($node, $return = TRUE) { // 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 = strtotime($ingest_datetime); - $ingest_datetime = date('Y-m-d g:i P', $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()); From d1e4fac42a030bd26deeee53906a54e6fafce8ee Mon Sep 17 00:00:00 2001 From: Jeremy Lichtman Date: Tue, 9 Oct 2018 14:19:49 -0400 Subject: [PATCH 3/3] ZD-279: Fix bracket. --- modules/telvue_push/telvue_push.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/telvue_push/telvue_push.module b/modules/telvue_push/telvue_push.module index d504a3d..a16c5e5 100644 --- a/modules/telvue_push/telvue_push.module +++ b/modules/telvue_push/telvue_push.module @@ -414,7 +414,7 @@ function telvue_push_push($node, $return = TRUE) { 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)); + $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');