Skip to content

Commit

Permalink
chore(libsinsp): remove unused parse_iso8601_utc_string function
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
  • Loading branch information
therealbobo authored and poiana committed Feb 16, 2024
1 parent ff73cf5 commit 82fa06c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 33 deletions.
28 changes: 0 additions & 28 deletions userspace/libsinsp/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1049,34 +1049,6 @@ void sinsp_utils::ts_to_iso_8601(uint64_t ts, OUT std::string* res)
// Time utility functions.
///////////////////////////////////////////////////////////////////////////////

bool sinsp_utils::parse_iso_8601_utc_string(const std::string& time_str, uint64_t &ns)
{
#ifndef _WIN32
tm tm_time{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
char* rem = strptime(time_str.c_str(), "%Y-%m-%dT%H:%M:", &tm_time);
if(rem == NULL || *rem == '\0')
{
return false;
}
tm_time.tm_isdst = -1; // strptime does not set this, signal timegm to determine DST
ns = timegm(&tm_time) * ONE_SECOND_IN_NS;

// Handle the possibly fractional seconds now. Also verify
// that the string ends with Z.
double fractional_secs;
if(sscanf(rem, "%lfZ", &fractional_secs) != 1)
{
return false;
}

ns += (fractional_secs * ONE_SECOND_IN_NS);

return true;
#else
throw sinsp_exception("parse_iso_8601_utc_string() not implemented on Windows");
#endif
}

time_t get_epoch_utc_seconds(const std::string& time_str, const std::string& fmt)
{
#ifndef _WIN32
Expand Down
5 changes: 0 additions & 5 deletions userspace/libsinsp/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,6 @@ class sinsp_utils

static void ts_to_iso_8601(uint64_t ts, OUT std::string* res);

// Limited version of iso 8601 time string parsing, that assumes a
// timezone of Z for UTC, but does support parsing fractional seconds,
// unlike get_epoch_utc_seconds_* below.
static bool parse_iso_8601_utc_string(const std::string& time_str, uint64_t &ns);

//
// Convert caps from their numeric representation to a space-separated string list
//
Expand Down

0 comments on commit 82fa06c

Please # to comment.