Remove utils::TimeFromStructTimespec().
Use base::Time::FromTimeSpec() instead.
Test: mma
Change-Id: I0f2244b52188e8964a3eebc7f6188706105b850f
diff --git a/common/utils.cc b/common/utils.cc
index 844777a..c609013 100644
--- a/common/utils.cc
+++ b/common/utils.cc
@@ -914,12 +914,6 @@
return base_code;
}
-Time TimeFromStructTimespec(struct timespec *ts) {
- int64_t us = static_cast<int64_t>(ts->tv_sec) * Time::kMicrosecondsPerSecond +
- static_cast<int64_t>(ts->tv_nsec) / Time::kNanosecondsPerMicrosecond;
- return Time::UnixEpoch() + TimeDelta::FromMicroseconds(us);
-}
-
string StringVectorToString(const vector<string> &vec_str) {
string str = "[";
for (vector<string>::const_iterator i = vec_str.begin();
diff --git a/common/utils.h b/common/utils.h
index 9da6990..4b83cc4 100644
--- a/common/utils.h
+++ b/common/utils.h
@@ -44,11 +44,6 @@
namespace utils {
-// Converts a struct timespec representing a number of seconds since
-// the Unix epoch to a base::Time. Sub-microsecond time is rounded
-// down.
-base::Time TimeFromStructTimespec(struct timespec *ts);
-
// Formats |vec_str| as a string of the form ["<elem1>", "<elem2>"].
// Does no escaping, only use this for presentation in error messages.
std::string StringVectorToString(const std::vector<std::string> &vec_str);
diff --git a/common/utils_unittest.cc b/common/utils_unittest.cc
index db88544..b30b2d2 100644
--- a/common/utils_unittest.cc
+++ b/common/utils_unittest.cc
@@ -287,24 +287,6 @@
"-1s");
}
-TEST(UtilsTest, TimeFromStructTimespecTest) {
- struct timespec ts;
-
- // Unix epoch (Thursday 00:00:00 UTC on Jan 1, 1970)
- ts = (struct timespec) {.tv_sec = 0, .tv_nsec = 0};
- EXPECT_EQ(base::Time::UnixEpoch(), utils::TimeFromStructTimespec(&ts));
-
- // 42 ms after the Unix billennium (Sunday 01:46:40 UTC on September 9, 2001)
- ts = (struct timespec) {.tv_sec = 1000 * 1000 * 1000,
- .tv_nsec = 42 * 1000 * 1000};
- base::Time::Exploded exploded = (base::Time::Exploded) {
- .year = 2001, .month = 9, .day_of_week = 0, .day_of_month = 9,
- .hour = 1, .minute = 46, .second = 40, .millisecond = 42};
- base::Time time;
- EXPECT_TRUE(base::Time::FromUTCExploded(exploded, &time));
- EXPECT_EQ(time, utils::TimeFromStructTimespec(&ts));
-}
-
TEST(UtilsTest, ConvertToOmahaInstallDate) {
// The Omaha Epoch starts at Jan 1, 2007 0:00 PST which is a
// Monday. In Unix time, this point in time is easily obtained via
diff --git a/update_attempter.cc b/update_attempter.cc
index 5efd257..5f32312 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -225,7 +225,7 @@
return;
}
- Time lsb_release_timestamp = utils::TimeFromStructTimespec(&sb.st_ctim);
+ Time lsb_release_timestamp = Time::FromTimeSpec(sb.st_ctim);
Time now = system_state_->clock()->GetWallclockTime();
TimeDelta age = now - lsb_release_timestamp;
if (age.InSeconds() < 0) {