UNPKG

raptor-journey-planner

Version:

Implementation of the Round bAsed Public Transit Optimized Router (Raptor) journey planning algorithm.

21 lines (20 loc) 587 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TimeParser = void 0; /** * Parses time strings and returns them as seconds from midnight. Caches results */ class TimeParser { timeCache = {}; /** * Convert a time string to seconds from midnight */ getTime(time) { if (!this.timeCache.hasOwnProperty(time)) { const [hh, mm, ss] = time.split(":"); this.timeCache[time] = (+hh) * 60 * 60 + (+mm) * 60 + (+ss); } return this.timeCache[time]; } } exports.TimeParser = TimeParser;