mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): japanpost improve timezone parse (#7682)
This commit is contained in:
@@ -39,14 +39,16 @@ module.exports = async (ctx) => {
|
||||
const listOdd = list.odd();
|
||||
|
||||
const packageType = $('.tableType01').eq(0).find('tr').eq(1).find('td').eq(1).text().trim();
|
||||
const packageService = $('.tableType01').eq(0).find('tr').eq(1).find('td').eq(2).text().trim();
|
||||
const serviceText = locale === 'ja' ? '付加サービス:' : 'Additional services: ';
|
||||
|
||||
let lastItemTimeStamp;
|
||||
let tz;
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${baseTitle} ${packageType} ${reqCode}`,
|
||||
title: `${baseTitle} ${reqCode} ${packageType}`,
|
||||
link: link,
|
||||
description: `${baseTitle} ${packageType} ${reqCode}`,
|
||||
description: `${baseTitle} ${reqCode} ${packageType}`,
|
||||
language: locale,
|
||||
item: listEven
|
||||
.map((index, item) => {
|
||||
@@ -79,10 +81,13 @@ module.exports = async (ctx) => {
|
||||
itemDescription += `<br>${i}`;
|
||||
}
|
||||
}
|
||||
if (packageService) {
|
||||
itemDescription += '<br>' + serviceText + packageService;
|
||||
}
|
||||
}
|
||||
|
||||
const itemPubDateText = itemTd.eq(0).text().trim();
|
||||
const itemGuid = utils.generateGuid(itemTitle + itemDescription + itemPubDateText);
|
||||
const itemGuid = utils.generateGuid(reqCode + itemTitle + itemDescription + itemPubDateText);
|
||||
|
||||
let thisItemTimeStamp;
|
||||
[thisItemTimeStamp, tz] = utils.parseDatetime(itemPubDateText, packageOffice, packageRegion, tz, locale);
|
||||
|
||||
@@ -64,12 +64,10 @@ const utils = {
|
||||
customFormat = dayjs(t, formatEnDate, true).isValid() ? formatEnDate : dayjs(t, formatEnDateTime, true).isValid() ? formatEnDateTime : undefined;
|
||||
break;
|
||||
}
|
||||
if (!customFormat) {
|
||||
return [new Date(t).getTime(), tz];
|
||||
}
|
||||
|
||||
if (o) {
|
||||
if (o.indexOf('郵便局') !== -1) {
|
||||
const packageInJPKeywords = [['郵便局'], ['都', '道', '府', '県']];
|
||||
if (packageInJPKeywords[0].some((i) => o.includes(i)) || packageInJPKeywords[1].some((i) => r.includes(i))) {
|
||||
tz = 'Asia/Tokyo';
|
||||
} else {
|
||||
const oS = o.replace(' EMS', '').replace(' INT', '');
|
||||
@@ -84,7 +82,12 @@ const utils = {
|
||||
}
|
||||
}
|
||||
}
|
||||
return [dayjs.tz(t, customFormat, tz).valueOf(), tz];
|
||||
|
||||
if (!customFormat) {
|
||||
return [new Date(t).getTime(), tz];
|
||||
} else {
|
||||
return [dayjs.tz(t, customFormat, tz).valueOf(), tz];
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user