Add AIS last position timestamp to details view.

This commit is contained in:
Jared Boone 2016-01-15 18:15:34 -08:00
parent 6ead63d02d
commit 93aea59847
3 changed files with 11 additions and 0 deletions

View File

@ -410,6 +410,7 @@ void AISRecentEntryDetailView::paint(Painter& painter) {
field_rect = draw_field(painter, field_rect, s, "Name", entry_.name);
field_rect = draw_field(painter, field_rect, s, "Call", entry_.call_sign);
field_rect = draw_field(painter, field_rect, s, "Dest", entry_.destination);
field_rect = draw_field(painter, field_rect, s, "Last", to_string_datetime(entry_.last_position.timestamp));
field_rect = draw_field(painter, field_rect, s, "Pos ", ais::format::latlon(entry_.last_position.latitude, entry_.last_position.longitude));
field_rect = draw_field(painter, field_rect, s, "Stat", ais::format::navigational_status(entry_.navigational_status));
field_rect = draw_field(painter, field_rect, s, "Rx #", to_string_dec_uint(entry_.received_count));

View File

@ -112,6 +112,15 @@ std::string to_string_hex(const uint32_t n, const int32_t l) {
return p;
}
std::string to_string_datetime(const rtc::RTC& value) {
return to_string_dec_uint(value.year(), 4, '0') + "/" +
to_string_dec_uint(value.month(), 2, '0') + "/" +
to_string_dec_uint(value.day(), 2, '0') + " " +
to_string_dec_uint(value.hour(), 2, '0') + ":" +
to_string_dec_uint(value.minute(), 2, '0') + ":" +
to_string_dec_uint(value.second(), 2, '0');
}
std::string to_string_timestamp(const rtc::RTC& value) {
return to_string_dec_uint(value.year(), 4, '0') +
to_string_dec_uint(value.month(), 2, '0') +

View File

@ -35,6 +35,7 @@ std::string to_string_dec_uint(const uint32_t n, const int32_t l = 0, const char
std::string to_string_dec_int(const int32_t n, const int32_t l = 0, const char fill = 0);
std::string to_string_hex(const uint32_t n, const int32_t l = 0);
std::string to_string_datetime(const rtc::RTC& value);
std::string to_string_timestamp(const rtc::RTC& value);
#endif/*__STRING_FORMAT_H__*/