Skip to content

Commit

Permalink
(fix): ensure certain relative dates can be parsed
Browse files Browse the repository at this point in the history
- "hours ago", "days ago", "Today", "Yesteday", etc
  - this seems to be all permutations for this provider at least
- for now just convert them to Date.now(), but ideally number of
  days or hours should actually be subtracted out for an accurate date
  - this is a much simpler fix right now, but it may be confusing to
    users who know their release dates, so not ideal
  • Loading branch information
agilgur5 committed Nov 22, 2019
1 parent fbfdb89 commit 572fbd6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion models/scraperDrivers/driver1.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,17 @@ export function getChapters ($) {
const title = $('.manga-detail-top .title').text().trim()
const chapters = $('.chlist a')
.map((index, el) => {
const dateText = $(el).find(':not(.newch)').text()
// if "hours ago". "days ago", "Today", etc, just use now
const isRelative = dateText.includes('ago') ||
dateText.includes('Today') ||
dateText.includes('Yesterday')
const date = new Date(isRelative ? Date.now() : dateText)

return {
link: $(el).attr('href').replace('//', 'http://'),
title: $(el).text().match(/[0-9]+/)[0] || '0',
date: new Date($(el).find(':not(.newch)').text())
date
}
})
.get()
Expand Down

0 comments on commit 572fbd6

Please sign in to comment.