diff --git a/TimeTrace/src/models/LogFormatter.ts b/TimeTrace/src/models/LogFormatter.ts index 9fc07f6..026a93b 100644 --- a/TimeTrace/src/models/LogFormatter.ts +++ b/TimeTrace/src/models/LogFormatter.ts @@ -2,12 +2,11 @@ export class LogFormatter { - //THIS IS NOT RELEVANT IN PRODUCTION // file: File; // constructor() { //ONLY TO CREATE FAKE IN MEMORY FILE FOR TESTING - // this.file = new File(["1 login\n2 logout\n3 login\n4 logout\n4 singin\n"], "original_log.txt"); + // this.file = new File(["2024-02-06T09:45:24.3100333Z login\n2024-02-06T09:45:26.3100333Z logout\n2024-02-06T09:47:24.3100333Z login\n2024-02-06T09:55:24.3100333Z logout\n2024-02-06T19:45:24.3100333Z singin\n"], "original_log.txt"); // } - //******************************* */ + async getFileLines(original_log: File): Promise { return new Promise((resolve, reject) => { //must return promise because reader is async @@ -46,7 +45,7 @@ export class LogFormatter { let event: string = line_elements[1]; //event is second element let timestamp: string = line_elements[0]; // timestamp is first element map_value = this.getMapValue(event, mappings) - mapped_rows.push(map_value+ " " + timestamp) //format data + mapped_rows.push(map_value+ " " + this.convertDateformat(timestamp)) //format data } }); return mapped_rows; @@ -59,4 +58,9 @@ export class LogFormatter { } return map_value } + + convertDateformat(timestamp: string): string { + let miliseconds: number = Date.parse(timestamp) + return miliseconds.toString() + } } \ No newline at end of file