From 2d4271c61934339a15ebbbb4cf1c3fd079af4f19 Mon Sep 17 00:00:00 2001 From: Jacob Keller Date: Wed, 12 Dec 2018 20:15:43 -0800 Subject: [PATCH] use new more precise duration calculation Use the new duration attribute from simpleArcParse, in order to extract duration in milliseconds. Display the time with precision up to 2 decimal places. Stop storing the old server_end.json file, as we will rely only on the new duration value. However, for formatting encounters, allow using the old method if we haven't yet extracted the precise_duration. Signed-off-by: Jacob Keller --- l0g-101086.psm1 | 25 ++++++++++++++++++------- upload-logs.ps1 | 16 ++++------------ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/l0g-101086.psm1 b/l0g-101086.psm1 index de5e818..e738fdd 100644 --- a/l0g-101086.psm1 +++ b/l0g-101086.psm1 @@ -1208,14 +1208,25 @@ Function Load-From-EVTC { $boss["servertime"] = [int]$servertime $boss["time"] = ConvertFrom-UnixDate $servertime - # Get the encounter duration (in difference of unix timestamps) - $duration_json = [io.path]::combine($extras_path, "duration.json") - if (X-Test-Path $duration_json) { - $duration = (Get-Content -Raw -Path $duration_json | ConvertFrom-Json) - $boss["duration"] = [int]$duration - $span = New-TimeSpan -Seconds $duration - $duration_string = "$([math]::floor($span.TotalMinutes))m $($span.Seconds.ToString("00"))s" + $precise_duration_json = [io.path]::combine($extras_path, "precise_duration.json") + if (X-Test-Path $precise_duration_json) { + $precise_duration = (Get-Content -Raw -Path $precise_duration_json | ConvertFrom-Json) + $boss["duration"] = [int]($precise_duration / 1000) + $span = [TimeSpan]::FromMilliseconds($precise_duration) + $minutes = New-TimeSpan -Minutes ([math]::floor($span.TotalMinutes)) + $millis = $span - $minutes + $duration_string = "$($minutes.Minutes)m $(($millis.TotalMilliseconds / 1000).ToString("00.00"))s" $boss["duration_string"] = $duration_string + } else { + # Get the encounter duration (in difference of unix timestamps) + $duration_json = [io.path]::combine($extras_path, "duration.json") + if (X-Test-Path $duration_json) { + $duration = (Get-Content -Raw -Path $duration_json | ConvertFrom-Json) + $boss["duration"] = [int]$duration + $span = New-TimeSpan -Seconds $duration + $duration_string = "$([math]::floor($span.TotalMinutes))m $($span.Seconds.ToString("00"))s" + $boss["duration_string"] = $duration_string + } } # Get the encounter name diff --git a/upload-logs.ps1 b/upload-logs.ps1 index f40aa0c..fa7731a 100644 --- a/upload-logs.ps1 +++ b/upload-logs.ps1 @@ -237,24 +237,16 @@ ForEach($f in $files) { Log-Output "Outcome: ${evtc_success}" + # Extract the precise duration in milliseconds + $precise_duration = (& $simple_arc_parse duration "${evtc}") + $precise_duration | ConvertTo-Json | Out-File -FilePath (Join-Path $dir -ChildPath "precise_duration.json") + # Parse the evtc combat events to determine the server start time $start_time = (& $simple_arc_parse start_time "${evtc}") $start_time | ConvertTo-Json | Out-File -FilePath (Join-Path $dir -ChildPath "servertime.json") Log-Output "Start Time: ${start_time}" - # Parse the evtc combat events to determine the server end time, then calculate a duration in seconds - $end_time = (& $simple_arc_parse end_time "${evtc}") - if ($end_time -le $start_time) { - Log-Output "End Time: ${end_time}" - Log-Output "The end time in the log file is less than the start time. Skipping duration calculation." - } else { - $duration = $end_time - $start_time - $duration | ConvertTo-Json | Out-File -FilePath (Join-Path $dir -ChildPath "duration.json") - - Log-Output "Encounter duration: ${duration}" - } - # Parse the evtc to determine if the encounter was a challenge mote $is_cm = (& $simple_arc_parse is_cm "${evtc}") $is_cm | ConvertTo-Json | Out-File -FilePath (Join-Path $dir -ChildPath "is_cm.json")