Merge remote-tracking branch 'origin/topic/jsiwek/gh-985-double-to-interval-descs'

* origin/topic/jsiwek/gh-985-double-to-interval-descs:
  GH-985: Fix descriptions of double_to_interval() return values
This commit is contained in:
Jon Siwek 2020-06-02 18:13:50 -07:00
commit a431f6b45d
5 changed files with 19 additions and 8 deletions

View file

@ -1,4 +1,12 @@
3.2.0-dev.738 | 2020-06-02 18:13:50 -0700
* GH-985: Fix descriptions of double_to_interval() return values (Jon Siwek, Corelight)
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".
3.2.0-dev.736 | 2020-06-02 12:37:56 -0700
* Decrease number of CPUs/memory for Cirrus CI tasks (Jon Siwek, Corelight)

View file

@ -1 +1 @@
3.2.0-dev.736
3.2.0-dev.738

View file

@ -2399,7 +2399,7 @@ function double_to_time%(d: double%): time
## .. zeek:see:: interval_to_double
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`.

View file

@ -1,2 +1,3 @@
1234563.14
-1234563.14
interval, 14.0 days 6.0 hrs 56.0 mins 3.0 secs 139.0 msecs 999.999898 usecs
interval, -14.0 days -6.0 hrs -56.0 mins -3.0 secs -139.0 msecs -999.999898 usecs
interval, 6.0 secs

View file

@ -4,8 +4,10 @@
event zeek_init()
{
local a = 1234563.14;
print double_to_interval(a);
local b = -1234563.14;
print double_to_interval(b);
local a = double_to_interval(1234563.140);
print type_name(a), a;
local b = double_to_interval(-1234563.14);
print type_name(b), b;
local c = double_to_interval(6.0);
print type_name(c), c;
}