flightDate in Legs shows previous month for departure/arrival flights
javiergarciagonzalez opened this issue · comments
Hi,
I am upgrading my Bcbp dependency from v4.0.2
to latest v5.1.0
.
While testing my application I saw that for boarding passes that contains julian date for today (7th of July), it shows the month of June
in the field flightDate
for a decoded flight's leg.
EXAMPLE
Using julian date 188 -> 7th of July
For this boarding pass: M1DOE/JOHN EXYZ123 AMSHKGKL 1021 188F035A0001 100
Result is:
{
passengerName: 'DOE/JOHN',
legs: [
{
operatingCarrierPNR: 'XYZ123',
departureAirport: 'AMS',
arrivalAirport: 'HKG',
operatingCarrierDesignator: 'KL',
flightNumber: '1021',
flightDate: 2021-06-06T23:00:00.000Z,
compartmentCode: 'F',
seatNumber: '035A',
checkInSequenceNumber: '0001',
passengerStatus: '1',
airlineNumericCode: undefined,
serialNumber: undefined,
selecteeIndicator: undefined,
internationalDocumentationVerification: undefined,
marketingCarrierDesignator: undefined,
frequentFlyerAirlineDesignator: undefined,
frequentFlyerNumber: undefined,
idIndicator: undefined,
freeBaggageAllowance: undefined,
fastTrack: undefined,
airlineInfo: undefined
}
],
passengerDescription: undefined,
checkInSource: undefined,
boardingPassIssuanceSource: undefined,
issuanceDate: undefined,
documentType: undefined,
boardingPassIssuerDesignator: undefined,
baggageTagNumber: undefined,
firstBaggageTagNumber: undefined,
secondBaggageTagNumber: undefined,
securityDataType: undefined,
securityData: undefined
}
where legs[0].flightDate
references to the 6th of June
, instead of 7th of July
.
Code for this example is:
const {decode} = require('bcbp');
console.log(decode("M1DOE/JOHN EXYZ123 AMSHKGKL 1021 188F035A0001 100", 2021));
It seems to be one day and month off.
Maybe I am doing something wrong here. Let me know if I can provide more info.
And thanks for your work, keep it up!
I'm struggling to replicate this issue. Please can you take a look at this and see if you get the same result: https://codesandbox.io/s/ecstatic-payne-gw0sr?file=/src/index.js
For me, I see Wed, 07 Jul 2021 00:00:00 GMT
I converted the dayOfYearToDate function to vanilla JS in v5 so it's possible that's doing something weird with timezones. I'll look into this a bit more later today.
Hey @georgesmith46 ,
First of all, thanks for answering this quickly!
This is what I get when I open your codesandbox link:
So it's Sun, 06 Jun 2021 23:00:00 GMT
for me. This is quite strange. Do you think I'm doing something wrong on my end?
If so, I'm really sorry for wasting your time. Thanks for your help.
Just checked with a colleague in the same time-zone that I am (Amsterdam GMT+2).
He's getting the same result as I get.
CC: @georgesmith46
Thanks for checking, it does appear to be a timezone issue. I've raised a PR which I hope will fix it.
🎉 This issue has been resolved in version 5.1.1 🎉
The release is available on:
Your semantic-release bot 📦🚀
You rock @georgesmith46, thank you so much!
I can confirm that the bug is fixed in the new version ✅