Skip to content

Commit

Permalink
Implement strftime-like formatting in fax URLs
Browse files Browse the repository at this point in the history
This can be used to download faxes where the date of the fax is encoded
into the URL (like surfacewinds_24hr_20170731_213000.gif).

All the standard strftime special sequences are supported, and the
<Map> XML tag can contain the DateOffset attribute in order to specify
an offset (in days) to be added/substracted to the current date.

For example:
  <Server Name="test" Url="http://www.test.net/">
    <Region Name="test">
      <Map Url="%Y%m%d.html" Contents="today" Area="1" />
      <Map Url="%Y%m%d.html" DateOffset="-1" Contents="yesterday" Area="1" />
      <Map Url="%Y%m%d.html" DateOffset="+1" Contents="tomorrow" Area="1" />
      <Area Name="1" lat1="40N" lat2="70N" lon1="50W" lon2="50E" />
    </Region>
  </Server>
  • Loading branch information
stelian42 committed Aug 9, 2017
1 parent fe129db commit b5dd474
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/InternetRetrievalDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,13 @@ bool InternetRetrievalDialog::OpenXML(wxString filename)
url.Scheduled = false;
url.Server = server.Name;
url.Region = region.Name;

url.Url = region_url + wxString::FromUTF8(g->Attribute("Url"));

long offset = 0;
wxString s_offset = wxString::FromUTF8(g->Attribute("DateOffset"));
s_offset.ToLong(&offset);
wxDateSpan dateSpan = wxDateSpan::Days(offset);
wxDateTime dateUrl = wxDateTime::UNow().Add(dateSpan);
url.Url = region_url + dateUrl.Format(wxString::FromUTF8(g->Attribute("Url")));
url.Contents = wxString::FromUTF8(g->Attribute("Contents"));
url.area_name = wxString::FromUTF8(g->Attribute("Area"));

Expand Down

0 comments on commit b5dd474

Please sign in to comment.