Fix handling in cases where there are no NRCC messages

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-09-11 20:47:38 +01:00
parent c1a5ce1fe9
commit b61851e122

View File

@ -34,10 +34,15 @@ export function transform(input: any): StaffLdb | null {
}
function transformDateTime(input: string): Date {
console.log("Transform Date Time Running")
return new Date(input);
}
function transformNrcc(input: any): NrccMessage[] | undefined {
console.log("Transform Nrcc Running")
if (input === undefined) {
return input
}
let output: NrccMessage[] = [];
let messages = input;
if (!Array.isArray(input?.message)) {
@ -57,6 +62,7 @@ function transformNrcc(input: any): NrccMessage[] | undefined {
}
function transformTrainServices(input: any): TrainServices[] {
console.log("Transform Train Services Running")
let services: any = input?.service;
let output: TrainServices[] = [];
if (services === undefined) {
@ -98,6 +104,7 @@ function transformTrainServices(input: any): TrainServices[] {
}
function transformLocation(input: any): ServiceLocation[] {
console.log("Transform Location Running")
let output: ServiceLocation[] = [];
let locations: any[] = input.location;
if (!Array.isArray(input.location)) {
@ -116,6 +123,7 @@ function transformLocation(input: any): ServiceLocation[] {
}
export function calculateLength(input: any): number | undefined {
console.log("Calculate Length Running")
let length: number;
if (input?.length) {
length = input.length;
@ -129,6 +137,7 @@ export function calculateLength(input: any): number | undefined {
}
function transformUnspecifiedDateTime(input: string): Date | undefined {
console.log("Transform Unspecified Date Time Running")
if (!input) {
return undefined;
}