hk-bus-eta 1.3.5 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Lrtfeeder.js +5 -3
- package/Nlb.js +2 -1
- package/package.json +1 -1
package/Lrtfeeder.js
CHANGED
|
@@ -17,12 +17,14 @@ module.exports = {
|
|
|
17
17
|
.then(({busStop}) =>
|
|
18
18
|
busStop.filter(({busStopId}) => busStopId === stopId)
|
|
19
19
|
.reduce((ret, {bus: buses}) => ([...ret, ...buses.reduce( (etas, bus) => {
|
|
20
|
-
|
|
20
|
+
// hackily use +8 hours and use UTC hour to resolve timezone issue
|
|
21
|
+
const etaDate = new Date(Date.now() + parseInt(bus.arrivalTimeInSecond === "108000" ? bus.departureTimeInSecond : bus.arrivalTimeInSecond, 10) * 1000 + 8 * 3600000);
|
|
22
|
+
|
|
21
23
|
return [
|
|
22
24
|
...etas,
|
|
23
25
|
{
|
|
24
|
-
eta: `${etaDate.
|
|
25
|
-
+`T${`0${etaDate.
|
|
26
|
+
eta: `${etaDate.getUTCFullYear()}-${`0${etaDate.getUTCMonth() + 1}`.slice(-2)}-${`0${etaDate.getUTCDate()}`.slice(-2)}`
|
|
27
|
+
+`T${`0${etaDate.getUTCHours()}`.slice(-2)}:${`0${etaDate.getMinutes()}`.slice(-2)}:${`0${etaDate.getSeconds()}`.slice(-2)}+08:00`,
|
|
26
28
|
remark: {
|
|
27
29
|
[language]: bus.busRemark || ( bus.isScheduled === "1" ? ( language === "en" ? "Scheduled" : "預定班次" ) : "" )
|
|
28
30
|
},
|
package/Nlb.js
CHANGED
|
@@ -18,8 +18,9 @@ module.exports = {
|
|
|
18
18
|
response => response.json()
|
|
19
19
|
).then(({estimatedArrivals}) => {
|
|
20
20
|
if ( !estimatedArrivals ) return []
|
|
21
|
+
|
|
21
22
|
return estimatedArrivals.filter(eta => eta.estimatedArrivalTime).map(e => ({
|
|
22
|
-
eta: e.estimatedArrivalTime,
|
|
23
|
+
eta: e.estimatedArrivalTime.replace(' ', 'T') + '.000+08:00',
|
|
23
24
|
remark: {
|
|
24
25
|
zh: '',
|
|
25
26
|
en: ''
|