mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-19 03:09:14 +08:00
chore: test parseRelativeDate in cloudflare
This commit is contained in:
parent
182af0cf9a
commit
414b1c7164
@ -15,7 +15,6 @@ export default defineSource(async () => {
|
|||||||
const info = $(el).find(".time > span:nth-child(1)").text()
|
const info = $(el).find(".time > span:nth-child(1)").text()
|
||||||
// 第三个 p
|
// 第三个 p
|
||||||
const relatieveTime = $(el).find(".time > span:nth-child(3)").text()
|
const relatieveTime = $(el).find(".time > span:nth-child(3)").text()
|
||||||
console.log(relatieveTime)
|
|
||||||
if (url && title && relatieveTime) {
|
if (url && title && relatieveTime) {
|
||||||
news.push({
|
news.push({
|
||||||
url: baseURL + url,
|
url: baseURL + url,
|
||||||
|
@ -150,6 +150,7 @@ export function parseRelativeDate(date: string, timezone: string = "UTC") {
|
|||||||
|
|
||||||
const matches = theDate.match(/\D*\d+(?![:\-/]|(a|p)m)\D+/g)
|
const matches = theDate.match(/\D*\d+(?![:\-/]|(a|p)m)\D+/g)
|
||||||
const offset = dayjs.duration({ hours: (dayjs().tz(timezone).utcOffset() - dayjs().utcOffset()) / 60 })
|
const offset = dayjs.duration({ hours: (dayjs().tz(timezone).utcOffset() - dayjs().utcOffset()) / 60 })
|
||||||
|
console.log((dayjs().tz(timezone).utcOffset() - dayjs().utcOffset()) / 60)
|
||||||
|
|
||||||
if (matches) {
|
if (matches) {
|
||||||
// 获得最后的时间单元,如 `\d+秒前`
|
// 获得最后的时间单元,如 `\d+秒前`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user