From a857efdeeeb1ed38c34728cbd5295ea1fa3b1b7a Mon Sep 17 00:00:00 2001 From: "aldin.alagicc@gmail.com" Date: Fri, 23 Dec 2022 13:03:45 +0100 Subject: [PATCH 1/2] Fix UPS tracker incorrectly parsing the 12-hour time component --- lib/courier/ups.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/courier/ups.js b/lib/courier/ups.js index fc2b36f..6013f0f 100644 --- a/lib/courier/ups.js +++ b/lib/courier/ups.js @@ -88,7 +88,8 @@ module.exports = function (opts) { location: current.location, message: current.activityScan.trim(), status: tracker.STATUS.IN_TRANSIT, - time: moment([current.date, current.time].join(' '), 'MM/DD/YYYY HH:mm').format('YYYY-MM-DDTHH:mmZ') + // 10/20/2020 3:17 A.M. + time: moment([current.date, current.time].join(' '), 'MM/DD/YYYY h:mm a').format('YYYY-MM-DDTHH:mmZ') } if (checkpoint.message.indexOf('DELIVERED') !== -1) { From e29fa773d26a695549040bbcf4ea34310a548099 Mon Sep 17 00:00:00 2001 From: "aldin.alagicc@gmail.com" Date: Fri, 23 Dec 2022 13:04:33 +0100 Subject: [PATCH 2/2] Fix USPS tracker not parsing time correctly due to extra spaces in middle of time string --- lib/courier/usps.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/courier/usps.js b/lib/courier/usps.js index 2b5aa5d..8c8b172 100644 --- a/lib/courier/usps.js +++ b/lib/courier/usps.js @@ -42,9 +42,9 @@ var parser = { location: $(element).find('.tb-location').text().trim(), message: $(element).find('.tb-status-detail').text(), status: tracker.STATUS.IN_TRANSIT, - // November 17, 2017, 3:08 pm + // November 17, 2017, 3:08 pm time: moment( - $(element).find('.tb-date').text().trim(), + $(element).find('.tb-date').text().replace(/\s+/g, ' ').trim(), 'MMMM DD, YYYY, hh:mm a' ).format('YYYY-MM-DDTHH:mm') }