diff --git a/CHANGES b/CHANGES index 10c1b8a139..6e206f1761 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,8 @@ +3.3.0-dev.593 | 2020-12-02 12:53:04 -0800 + + * Add `count_to_double` and `int_to_double` bif functions (Yacin Nadji, Corelight) + 3.3.0-dev.590 | 2020-12-02 11:11:26 -0800 * Update minimum required CMake to 3.5 (Jon Siwek, Corelight) diff --git a/NEWS b/NEWS index edfcfc3f38..7ab348fb4f 100644 --- a/NEWS +++ b/NEWS @@ -84,6 +84,8 @@ New Functionality is a special version indicating that the server/client supports both SSH2 and SSH1. +- Added ``count_to_double()`` and ``int_to_double()`` type-conversion BIFs. + Changed Functionality --------------------- diff --git a/VERSION b/VERSION index 108f7df1a9..e1b3dfaacc 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.3.0-dev.590 +3.3.0-dev.593 diff --git a/src/zeek.bif b/src/zeek.bif index 81981283a9..0444a881de 100644 --- a/src/zeek.bif +++ b/src/zeek.bif @@ -2537,6 +2537,30 @@ function interval_to_double%(i: interval%): double return zeek::make_intrusive(i); %} +## Converts a :zeek:type:`count` to a :zeek:type:`double`. +## +## c: The :zeek:type:`count` to convert. +## +## Returns: The :zeek:type:`count` *c* as :zeek:type:`double`. +## +## .. zeek:see:: int_to_double double_to_count +function count_to_double%(c: count%): double + %{ + return zeek::make_intrusive(c); + %} + +## Converts an :zeek:type:`int` to a :zeek:type:`double`. +## +## i: The :zeek:type:`int` to convert. +## +## Returns: The :zeek:type:`int` *i* as :zeek:type:`double`. +## +## .. zeek:see:: count_to_double double_to_count +function int_to_double%(i: int%): double + %{ + return zeek::make_intrusive(i); + %} + ## Converts a :zeek:type:`time` value to a :zeek:type:`double`. ## ## t: The :zeek:type:`time` to convert. diff --git a/testing/btest/Baseline/bifs.to_double/out b/testing/btest/Baseline/bifs.to_double/out index 8e172dcaa6..55f4f21829 100644 --- a/testing/btest/Baseline/bifs.to_double/out +++ b/testing/btest/Baseline/bifs.to_double/out @@ -4,3 +4,6 @@ 3600.0 86400.0 1342748947.655087 +0.0 +10000.0 +-41.0 diff --git a/testing/btest/bifs/to_double.zeek b/testing/btest/bifs/to_double.zeek index d62d30d5af..0247ae9ef3 100644 --- a/testing/btest/bifs/to_double.zeek +++ b/testing/btest/bifs/to_double.zeek @@ -17,4 +17,11 @@ event zeek_init() local f = current_time(); print time_to_double(f); + + local g = 0; + print count_to_double(g); + local h = 10000; + print count_to_double(h); + local i = -41; + print int_to_double(i); }