mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-22 22:59:35 +02:00
parse date & time ⌚
This commit is contained in:
parent
66dfc73259
commit
5b0a4034cf
1 changed files with 15 additions and 0 deletions
15
parse.js
15
parse.js
|
@ -1,5 +1,20 @@
|
|||
'use strict'
|
||||
|
||||
const moment = require('moment-timezone')
|
||||
|
||||
|
||||
|
||||
const dateTime = (timezone) => (date, time) => {
|
||||
let offset = 0 // in days
|
||||
if (time.length > 6) {
|
||||
offset = +time.slice(0, -6)
|
||||
time = time.slice(-6)
|
||||
}
|
||||
return moment.tz(date + 'T' + time, timezone)
|
||||
.add(offset, 'days')
|
||||
.valueOf()
|
||||
}
|
||||
|
||||
|
||||
|
||||
const types = {P: 'poi', S: 'station', A: 'address'}
|
||||
|
|
Loading…
Add table
Reference in a new issue