-
Notifications
You must be signed in to change notification settings - Fork 132
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
Tiny Duration Fix #3119
Tiny Duration Fix #3119
Conversation
@@ -14,10 +15,10 @@ export class ZeekEvent implements SecurityEventInterface { | |||
|
|||
getEndTime() { | |||
if (this.r.get("_path").toString() !== "conn") return null | |||
const dur = this.r.get<zed.Duration>("duration").asSeconds() | |||
if (!dur) return | |||
const dur = this.r.get<zed.Duration>("duration").asMs() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use milliseconds here instead of seconds, to get the most precision we can.
@@ -14,7 +14,11 @@ export default function formatDir(start, end) { | |||
parts.push(formatPart(obj[unit], unit)) | |||
} | |||
if (allZero) { | |||
parts.push(formatPart((end.getTime() - start.getTime()) / 1000, "seconds")) | |||
if (end.getTime() === start.getTime()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if the two dates are the same to determine if the duration is less than 1ms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix seems effective. I saw one of the tests was broken so I pushed a commit to fix it.
Thanks Phil! |
Fixes #3101
With this fix:
If the duration is less than 1 second, it will display "xxxmilliseconds"
If it is less than 1 millisecond, it will display "less than one millisecond"