deal with some todos, add more

This commit is contained in:
Jannis R 2017-12-12 23:15:06 +01:00
parent 040ed41de7
commit 024aa0e948
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
7 changed files with 13 additions and 10 deletions

View file

@ -3,8 +3,9 @@
const formatCoord = require('./coord')
const formatAddress = (a) => {
// todo: type-checking, better error msgs
if (!a.latitude || !a.longitude || !a.name) throw new Error('invalid address.')
if (!a.type !== 'location' || !a.latitude || !a.longitude || !a.address) {
throw new Error('invalid address')
}
return {
type: 'A',

View file

@ -3,8 +3,9 @@
const formatCoord = require('./coord')
const formatPoi = (p) => {
// todo: type-checking, better error msgs
if (!p.latitude || !p.longitude || !p.id || !p.name) throw new Error('invalid poi.')
if (!p.type !== 'location' || !p.latitude || !p.longitude || !p.id || !p.name) {
throw new Error('invalid POI')
}
return {
type: 'P',

View file

@ -42,7 +42,7 @@ const transformJourneysQuery = (query, opt) => {
if (opt.bike) filters.push(bike)
query.trfReq = {
jnyCl: 2, // todo
jnyCl: opt.firstClass === true ? 1 : 2,
tvlrProf: [{
type: 'E',
redtnCard: opt.loyaltyCard

View file

@ -11,7 +11,6 @@ const createParseJourney = (profile, stations, lines, remarks) => {
// todo: c.dep.dProgType, c.arr.dProgType
// todo: c.conSubscr
// todo: c.trfRes x vbb-parse-ticket
// todo: use computed information from part
const parseJourney = (j) => {
const parts = j.secL.map(part => parsePart(j, part))
const res = {

View file

@ -16,7 +16,7 @@ const {
assertValidLocation,
assertValidLine,
assertValidStopover,
when, isValidWhen // todo: timezone
when, isValidWhen
} = require('./util.js')
const assertValidStationProducts = (t, p) => {

View file

@ -89,8 +89,10 @@ const hour = 60 * 60 * 1000
const week = 7 * 24 * hour
// next Monday 10 am
const dt = DateTime.local().startOf('week').plus({weeks: 1, hours: 10})
const when = new Date(dt.toISO())
const when = DateTime.fromMillis(Date.now(), {
zone: 'Europe/Berlin',
locale: 'de-DE'
}).startOf('week').plus({weeks: 1, hours: 10}).toJSDate()
const isValidWhen = (w) => {
const ts = +new Date(w)
if (Number.isNaN(ts)) return false

View file

@ -19,7 +19,7 @@ const {
assertValidLine: _assertValidLine,
assertValidStopover,
hour, when,
assertValidWhen, // todo: timezone
assertValidWhen,
assertValidTicket
} = require('./util')