[time-offset] add days to offset

Fixes #435
pull/233/merge
Timothy Stack 7 years ago
parent 6306659362
commit 9d249004ac

@ -142,6 +142,7 @@ noinst_HEADERS = \
default-log-formats-json.hh \
db_sub_source.hh \
doc_status_source.hh \
doctest.hh \
elem_to_json.hh \
environ_vtab.hh \
field_overlay_source.hh \

File diff suppressed because it is too large Load Diff

@ -329,7 +329,8 @@ size_t str2reltime(int64_t millis, std::string &value_out)
{ 1000, "%03qd%s", "" },
{ 60, "%qd%s", "s" },
{ 60, "%qd%s", "m" },
{ 0, "%qd%s", "h" },
{ 24, "%qd%s", "h" },
{ 0, "%qd%s", "d" },
{ 0, NULL, NULL }
};
@ -366,3 +367,4 @@ size_t str2reltime(int64_t millis, std::string &value_out)
return retval;
}

@ -1,6 +1,11 @@
include_directories(../../lbuild/src ../src/ /opt/local/include)
add_executable(lnav_doctests
lnav_doctests.cc
../src/relative_time.cc
../src/pcrepp.cc
../src/lnav_log.cc)
add_executable(test_pcrepp test_pcrepp.cc ../src/lnav_log.cc ../src/pcrepp.cc)
add_executable(test_reltime test_reltime.cc
../src/relative_time.cc
@ -24,6 +29,7 @@ add_executable(drive_sql_anno drive_sql_anno.cc ../src/lnav_log.cc ../src/pcrepp
link_directories(/opt/local/lib)
target_link_libraries(test_pcrepp /opt/local/lib/libpcre.a)
target_link_libraries(test_reltime /opt/local/lib/libpcre.a)
target_link_libraries(lnav_doctests /opt/local/lib/libpcre.a)
target_link_libraries(test_date_time_scanner /opt/local/lib/libpcre.a)
target_link_libraries(test_abbrev /opt/local/lib/libpcre.a)
target_link_libraries(drive_sql_anno /opt/local/lib/libpcre.a)

@ -31,6 +31,7 @@ check_PROGRAMS = \
drive_view_colors \
drive_vt52_curses \
drive_readline_curses \
lnav_doctests \
slicer \
scripty \
test_abbrev \
@ -126,6 +127,9 @@ test_json_ptr_LDADD = ../src/libdiag.a
test_reltime_SOURCES = test_reltime.cc
test_reltime_LDADD = ../src/libdiag.a
lnav_doctests_SOURCES = lnav_doctests.cc
lnav_doctests_LDADD = ../src/libdiag.a
drive_line_buffer_SOURCES = drive_line_buffer.cc
drive_line_buffer_LDADD = ../src/libdiag.a $(CURSES_LIB) -lz $(CURSES_LIB)
@ -353,6 +357,7 @@ dist_noinst_DATA = \
log-samples/sample-ad31f12d2adabd07e3ddda3ad5b0dbf6b49c4c99.txt
TESTS = \
lnav_doctests \
test_abbrev \
test_ansi_scrubber \
test_auto_fd \

@ -1,5 +0,0 @@
{
"foobaz_log" : {
"abc" : def
}
}

@ -0,0 +1,56 @@
/**
* Copyright (c) 2017, Timothy Stack
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Timothy Stack nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.hh"
#include "relative_time.hh"
using namespace std;
TEST_CASE("str2reltime") {
string val;
str2reltime(25 * 60 * 60 * 1000 + 123, val);
CHECK(val == "1d1h0m0s");
val.clear();
str2reltime(10 * 1000 + 123, val);
CHECK(val == "10s123");
val.clear();
str2reltime(10 * 1000, val);
CHECK(val == "10s000");
val.clear();
str2reltime(100, val);
CHECK(val == "100");
val.clear();
str2reltime(0, val);
CHECK(val == "");
}
Loading…
Cancel
Save