Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/yb/common/hybrid_time.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,22 @@ string HybridTime::ToString() const {
boost::date_time::c_local_adjustor<boost::posix_time::ptime>::utc_to_local(utc_time);
auto date = local_time.date();
auto time_of_day = local_time.time_of_day();
auto days = (boost::posix_time::ptime(date) - start).hours() / 24;
int years = static_cast<int>(date.year()) - 1970;
int day_of_year = date.day_of_year() - 1; // Jan 1st is 1
auto time_of_day_str = boost::posix_time::to_simple_string(time_of_day);
if (logical) {
return Format("{ days: $0 time: $1 logical: $2 }", days, time_of_day_str, logical);
if (years > 0){
if (logical) {
return Format("{ years: $0 days: $1 time: $2 logical: $3 }", years, days, time_of_day_str, logical);
} else {
return Format("{ years: $0 days: $1 time: $2 }", years, days, time_of_day_str);
}
} else {
return Format("{ days: $0 time: $1 }", days, time_of_day_str);
}
if (logical) {
return Format("{ days: $0 time: $1 logical: $2 }", days, time_of_day_str, logical);
} else {
return Format("{ days: $0 time: $1 }", days, time_of_day_str);
}
}
}
}

Expand Down