Skip to content

Commit

Permalink
Merge pull request #222 from did-g/report_user_time_setting
Browse files Browse the repository at this point in the history
Report user time setting
  • Loading branch information
seandepagnier committed Sep 7, 2018
2 parents 19897d2 + cb02304 commit 19c6f94
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 14 deletions.
37 changes: 29 additions & 8 deletions src/ReportDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ void ReportDialog::SetRouteMapOverlays(std::list<RouteMapOverlay*> routemapoverl

page += _("Boat Filename") + _T(" ") + wxFileName(c.boatFileName).GetName() + _T("<dt>");
page += _("Route from ") + c.Start + _(" to ") + c.End + _T("<dt>");
page += _("Leaving ") + (*it)->StartTime().Format(_T("%x %X")) + _T("<dt>");
page += _("Leaving ") + FormatTime((*it)->StartTime()) + _T("<dt>");
if (d) {
page += _("Arriving ") + (*it)->EndTime().Format(_T("%x %X")) + _T("<dt>");
page += _("Arriving ") + FormatTime((*it)->EndTime()) + _T("<dt>");
page += _("Duration ") + ((*it)->EndTime() - (*it)->StartTime()).Format() + _T("<dt>");
}
page += _T("<p>");
Expand Down Expand Up @@ -147,6 +147,27 @@ void ReportDialog::SetRouteMapOverlays(std::list<RouteMapOverlay*> routemapoverl
m_htmlConfigurationReport->SetPage(page);
}

wxDateTime ReportDialog::DisplayedTime(wxDateTime t)
{
wxDateTime display_time = t;
if(m_WeatherRouting.m_SettingsDialog.m_cbUseLocalTime->GetValue())
display_time = t.FromUTC();
return display_time;
}

wxString ReportDialog::FormatTime(wxDateTime t)
{
wxString r = DisplayedTime(t).Format(_T("%x %X"));
#if 0
// XXX add this?
if(m_WeatherRouting.m_SettingsDialog.m_cbUseLocalTime->GetValue())
r += _(" (local)");
else
r += _T(" (UTC)");
#endif
return r;
}

void ReportDialog::GenerateRoutesReport()
{
if(!m_bReportStale)
Expand Down Expand Up @@ -213,7 +234,7 @@ void ReportDialog::GenerateRoutesReport()
}
}

page += _("<dt>Fastest configuration ") + fastest->StartTime().Format(_T("%x %X"));
page += _("<dt>Fastest configuration ") + FormatTime(fastest->StartTime());
page += wxString(_T(" ")) + _("avg speed") + wxString::Format
(_T(": %.2f "), fastest->RouteInfo(RouteMapOverlay::AVGSPEED))
+ _("knots");
Expand Down Expand Up @@ -247,8 +268,8 @@ void ReportDialog::GenerateRoutesReport()
break;

RouteMapOverlay *r = it->second;
wxDateTime s = r->StartTime();
wxDateTime e = r->EndTime();
wxDateTime s = DisplayedTime(r->StartTime());
wxDateTime e = DisplayedTime(r->EndTime());
// merge downwind
for(; it != sort_by_start.end(); it++) {
RouteMapOverlay *r = it->second;
Expand Down Expand Up @@ -283,7 +304,7 @@ void ReportDialog::GenerateRoutesReport()
}
page += RouteMapOverlay::sailingConditionText(best_sailing_comfort);
page += _T(" on ");
page += best_comfort_date.Format(_T("%x %X")) + _T(" UTC");
page += FormatTime(best_comfort_date);

page += _T("<dt>");
page += _("Cyclones") + wxString(_T(": "));
Expand Down Expand Up @@ -354,7 +375,7 @@ void ReportDialog::GenerateRoutesReport()
if(!first)
page += _(" and ");
first = false;
page += (*it2)->StartTime().Format(_T("%x"));
page += DisplayedTime((*it2)->StartTime()).Format(_T("%x"));

if(++it2 == cyclone_safe_routes.end())
break;
Expand All @@ -365,7 +386,7 @@ void ReportDialog::GenerateRoutesReport()
while(*it2 && ++it2 != cyclone_safe_routes.end());

it2--;
page += _(" to ") + (*it2)->StartTime().Format(_T("%x"));
page += _(" to ") + DisplayedTime((*it2)->StartTime()).Format(_T("%x"));
}
}
cyclonesfailed:;
Expand Down
3 changes: 2 additions & 1 deletion src/ReportDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ReportDialog : public ReportDialogBase
void OnClose( wxCommandEvent& event ) { Hide(); }

private:

wxDateTime DisplayedTime(wxDateTime t);
wxString FormatTime(wxDateTime t);
WeatherRouting &m_WeatherRouting;
};
13 changes: 8 additions & 5 deletions src/WeatherRouting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2170,19 +2170,22 @@ void WeatherRouting::Export(RouteMapOverlay &routemapoverlay)
{
std::list<PlotData> plotdata = routemapoverlay.GetPlotData(false);

if(plotdata.size() == 0) {
if(plotdata.empty()) {
wxMessageDialog mdlg(this, _("Empty Route, nothing to export\n"),
_("Weather Routing"), wxOK | wxICON_WARNING);
mdlg.ShowModal();
return;
}

// XXX double check time is really end time, not start time off by one.
RouteMapConfiguration c = routemapoverlay.GetConfiguration();

PlugIn_Track* newTrack = new PlugIn_Track;
newTrack->m_NameString = _("Weather Route") + " (" + c.Start + ")";
wxDateTime display_time = routemapoverlay.StartTime();
if(m_SettingsDialog.m_cbUseLocalTime->GetValue())
display_time = display_time.FromUTC();

newTrack->m_NameString = _("Weather Route ") + " (" +display_time.Format(_T("%x %H:%M")) + ")";

// XXX double check time is really end time, not start time off by one.
RouteMapConfiguration c = routemapoverlay.GetConfiguration();

for(std::list<PlotData>::iterator it = plotdata.begin(); it != plotdata.end(); it++) {
PlugIn_Waypoint* newPoint = new PlugIn_Waypoint
Expand Down

0 comments on commit 19c6f94

Please sign in to comment.