mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
GH-985: Fix descriptions of double_to_interval() return values
The BIF was not returning an IntervalVal which has an overriden ValDescribe() method that allows for prettier printing like "6.0 secs" instead of just "6.0".
This commit is contained in:
parent
7b0931058e
commit
e17487e799
3 changed files with 10 additions and 7 deletions
|
@ -2399,7 +2399,7 @@ function double_to_time%(d: double%): time
|
||||||
## .. zeek:see:: interval_to_double
|
## .. zeek:see:: interval_to_double
|
||||||
function double_to_interval%(d: double%): interval
|
function double_to_interval%(d: double%): interval
|
||||||
%{
|
%{
|
||||||
return make_intrusive<Val>(d, TYPE_INTERVAL);
|
return make_intrusive<IntervalVal>(d, Seconds);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
## Converts a :zeek:type:`port` to a :zeek:type:`count`.
|
## Converts a :zeek:type:`port` to a :zeek:type:`count`.
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
1234563.14
|
interval, 14.0 days 6.0 hrs 56.0 mins 3.0 secs 139.0 msecs 999.999898 usecs
|
||||||
-1234563.14
|
interval, -14.0 days -6.0 hrs -56.0 mins -3.0 secs -139.0 msecs -999.999898 usecs
|
||||||
|
interval, 6.0 secs
|
||||||
|
|
|
@ -4,8 +4,10 @@
|
||||||
|
|
||||||
event zeek_init()
|
event zeek_init()
|
||||||
{
|
{
|
||||||
local a = 1234563.14;
|
local a = double_to_interval(1234563.140);
|
||||||
print double_to_interval(a);
|
print type_name(a), a;
|
||||||
local b = -1234563.14;
|
local b = double_to_interval(-1234563.14);
|
||||||
print double_to_interval(b);
|
print type_name(b), b;
|
||||||
|
local c = double_to_interval(6.0);
|
||||||
|
print type_name(c), c;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue