Skip to content

Commit 5d53e06

Browse files
committed
[build] fix cmake for last change
1 parent 325ce5e commit 5d53e06

8 files changed

Lines changed: 127 additions & 41 deletions

File tree

src/base/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ add_library(
2020
lnav.console.cc
2121
lnav.console.win.cc
2222
lnav.gzip.cc
23+
lnav.tz.cc
2324
lnav_log.cc
2425
network.tcp.cc
2526
paths.cc
@@ -69,6 +70,7 @@ add_library(
6970
lnav.console.into.hh
7071
lnav.resolver.hh
7172
lnav.ryml.hh
73+
lnav.tz.hh
7274
log_level_enum.hh
7375
lrucache.hpp
7476
map_util.hh

src/base/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ noinst_HEADERS = \
6161
lnav.gzip.hh \
6262
lnav.resolver.hh \
6363
lnav.ryml.hh \
64+
lnav.tz.hh \
6465
log_level_enum.hh \
6566
lrucache.hpp \
6667
map_util.hh \
@@ -102,6 +103,7 @@ libbase_a_SOURCES = \
102103
lnav.console.cc \
103104
lnav.console.win.cc \
104105
lnav.gzip.cc \
106+
lnav.tz.cc \
105107
lnav_log.cc \
106108
network.tcp.cc \
107109
paths.cc \

src/base/lnav.tz.cc

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/**
2+
* Copyright (c) 2026, Timothy Stack
3+
*
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
*
9+
* * Redistributions of source code must retain the above copyright notice, this
10+
* list of conditions and the following disclaimer.
11+
* * Redistributions in binary form must reproduce the above copyright notice,
12+
* this list of conditions and the following disclaimer in the documentation
13+
* and/or other materials provided with the distribution.
14+
* * Neither the name of Timothy Stack nor the names of its contributors
15+
* may be used to endorse or promote products derived from this software
16+
* without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
19+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
22+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*
29+
* @file lnav.tz.cc
30+
*/
31+
32+
#include "lnav.tz.hh"
33+
34+
#include "attr_line.hh"
35+
#include "config.h"
36+
#include "itertools.similar.hh"
37+
#include "lnav_log.hh"
38+
39+
namespace lnav {
40+
41+
static attr_line_t&
42+
symbol_reducer(const std::string& elem, attr_line_t& accum)
43+
{
44+
return accum.append("\n ").append(lnav::roles::symbol(elem));
45+
}
46+
47+
Result<const date::time_zone*, lnav::console::user_message>
48+
locate_zone(string_fragment tz_name)
49+
{
50+
try {
51+
return Ok(date::locate_zone(tz_name.to_string_view()));
52+
} catch (const std::runtime_error& e) {
53+
attr_line_t note;
54+
55+
try {
56+
note = (date::get_tzdb().zones
57+
| lnav::itertools::map(&date::time_zone::name)
58+
| lnav::itertools::similar_to(tz_name.to_string())
59+
| lnav::itertools::fold(symbol_reducer, attr_line_t{}))
60+
.add_header("did you mean one of the following?");
61+
} catch (const std::runtime_error& e) {
62+
log_error("unable to get timezones: %s", e.what());
63+
}
64+
auto um = lnav::console::user_message::error(
65+
attr_line_t().append_quoted(tz_name).append(
66+
" is not a valid timezone"))
67+
.with_reason(e.what())
68+
.with_note(note)
69+
.move();
70+
return Err(um);
71+
}
72+
}
73+
74+
} // namespace lnav

src/base/lnav.tz.hh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* Copyright (c) 2026, Timothy Stack
3+
*
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
*
9+
* * Redistributions of source code must retain the above copyright notice, this
10+
* list of conditions and the following disclaimer.
11+
* * Redistributions in binary form must reproduce the above copyright notice,
12+
* this list of conditions and the following disclaimer in the documentation
13+
* and/or other materials provided with the distribution.
14+
* * Neither the name of Timothy Stack nor the names of its contributors
15+
* may be used to endorse or promote products derived from this software
16+
* without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
19+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
22+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*
29+
* @file lnav.tz.hh
30+
*/
31+
32+
#ifndef lnav_tz_hh
33+
#define lnav_tz_hh
34+
35+
#include "date/tz.h"
36+
#include "intern_string.hh"
37+
#include "lnav.console.hh"
38+
#include "result.h"
39+
40+
namespace lnav {
41+
42+
Result<const date::time_zone*, lnav::console::user_message> locate_zone(
43+
string_fragment tz_name);
44+
45+
} // namespace lnav
46+
47+
#endif

src/base/time_util.cc

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#include <date/ptz.h>
3838

3939
#include "config.h"
40-
#include "itertools.similar.hh"
4140
#include "lnav_log.hh"
4241

4342
namespace lnav {
@@ -231,39 +230,6 @@ local_time_to_info(date::local_seconds secs)
231230
return TZ_POSIX_UTC.value().get_info(secs);
232231
}
233232

234-
inline attr_line_t&
235-
symbol_reducer(const std::string& elem, attr_line_t& accum)
236-
{
237-
return accum.append("\n ").append(lnav::roles::symbol(elem));
238-
}
239-
240-
Result<const date::time_zone*, lnav::console::user_message>
241-
locate_zone(string_fragment tz_name)
242-
{
243-
try {
244-
return Ok(date::locate_zone(tz_name.to_string_view()));
245-
} catch (const std::runtime_error& e) {
246-
attr_line_t note;
247-
248-
try {
249-
note = (date::get_tzdb().zones
250-
| lnav::itertools::map(&date::time_zone::name)
251-
| lnav::itertools::similar_to(tz_name.to_string())
252-
| lnav::itertools::fold(symbol_reducer, attr_line_t{}))
253-
.add_header("did you mean one of the following?");
254-
} catch (const std::runtime_error& e) {
255-
log_error("unable to get timezones: %s", e.what());
256-
}
257-
auto um = lnav::console::user_message::error(
258-
attr_line_t().append_quoted(tz_name).append(
259-
" is not a valid timezone"))
260-
.with_reason(e.what())
261-
.with_note(note)
262-
.move();
263-
return Err(um);
264-
}
265-
}
266-
267233
} // namespace lnav
268234

269235
static time_t BAD_DATE = -1;

src/base/time_util.hh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
#include "config.h"
4444
#include "date/date.h"
4545
#include "date/tz.h"
46-
#include "lnav.console.hh"
47-
#include "result.h"
4846

4947
inline std::chrono::microseconds
5048
to_us(const timeval& tv)
@@ -93,9 +91,6 @@ struct duration_hasher {
9391
}
9492
};
9593

96-
Result<const date::time_zone*, lnav::console::user_message>
97-
locate_zone(string_fragment tz_name);
98-
9994
} // namespace lnav
10095

10196
tm* secs2tm(lnav::time64_t tim, tm* res);

src/lnav_commands.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
#include "command_executor.hh"
5959
#include "config.h"
6060
#include "curl_looper.hh"
61-
#include "date/tz.h"
61+
#include "base/lnav.tz.hh"
6262
#include "db_sub_source.hh"
6363
#include "field_overlay_source.hh"
6464
#include "hasher.hh"

src/time-extension-functions.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include "base/humanize.time.hh"
4141
#include "base/relative_time.hh"
4242
#include "config.h"
43-
#include "date/tz.h"
43+
#include "base/lnav.tz.hh"
4444
#include "ptimec.hh"
4545
#include "sql_util.hh"
4646
#include "vtab_module.hh"

0 commit comments

Comments
 (0)