Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert datetimes to miliseconds #33

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions TimeTrace/src/models/LogFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string[]> {
return new Promise<string[]>((resolve, reject) => { //must return promise because reader is async
Expand Down Expand Up @@ -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_event> <timestamp>
mapped_rows.push(map_value+ " " + this.convertDateformat(timestamp)) //format data <mapped_event> <timestamp>
}
});
return mapped_rows;
Expand All @@ -59,4 +58,9 @@ export class LogFormatter {
}
return map_value
}

convertDateformat(timestamp: string): string {
let miliseconds: number = Date.parse(timestamp)
return miliseconds.toString()
}
}