Skip to content

Commit 62dccac

Browse files
committed
[date_time_scanner] humanize should use current time as base time
1 parent f27420b commit 62dccac

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/base/date_time_scanner.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434

3535
#include "date_time_scanner.hh"
3636

37+
#include <time.h>
38+
3739
#include "config.h"
3840
#include "date_time_scanner.cfg.hh"
3941
#include "humanize.time.hh"
@@ -458,6 +460,12 @@ point::from(string_fragment in, std::optional<timeval> ref_point)
458460
timeval tv_abs;
459461
exttm tm;
460462

463+
{
464+
auto curr_time = ::time(nullptr);
465+
struct tm base_tm;
466+
localtime_r(&curr_time, &base_tm);
467+
dts.set_base_time(curr_time, base_tm);
468+
}
461469
auto scan_end = dts.scan(in.data(), in.length(), nullptr, &tm, tv_abs);
462470
if (scan_end != nullptr) {
463471
size_t matched_size = scan_end - in.data();

0 commit comments

Comments
 (0)