-
-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DB: support "best price search" #314
base: main
Are you sure you want to change the base?
Conversation
ce4b5b5
to
92712c7
Compare
const {res, common} = await profile.request({profile, opt}, userAgent, { | ||
cfg: {polyEnc: 'GPA'}, | ||
meth: 'BestPriceSearch', | ||
req: profile.transformJourneysQuery({profile, opt}, query), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a heads-up: There might be a case – that I can't think of right now though – that fails because transformJourneysQuery()
assumes a TripSearch
call.
throw new TypeError('opt.departure is invalid'); | ||
} | ||
const now = new Date(); | ||
let today = DateTime.fromObject({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, even though I told you to do it this way, I think this isn't correct either: For example, if profile.timezone
is Europe/Berlin
, the timezone-naive now
is 2024-05-06T00:30+01:00
because it runs on a machine in Europe/London
, then this will create a Berlin-timezone timestamp for the next day.
I can think of a least two options, the latter being the more straightforward one IMO:
- Change
now
to be timezone-aware, so thatnow.{year, month,day}
are correct. - Just use one chain of
DateTime
calls, as illustrated below.
Also, while implicitly casting today
to a number
below works, it would be cleaner to add .toMillis()
.
const today = DateTime
.fromMillis(Date.now(), {
zone: profile.timezone,
locale: profile.locale,
})
.startOf('day')
.toMillis()
remotely related: #331 |
@bergmannjg I went ahead and created a WIP PR.
Fixes #291.
Fixes juliuste/db-prices#33.
Fixes derhuerst/db-prices-cli#4.