Skip to content

Commit 49bfa12

Browse files
committed
compilation fixes Windows
1 parent efc5a52 commit 49bfa12

File tree

5 files changed

+28
-11
lines changed

5 files changed

+28
-11
lines changed

Library/ADSB.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ namespace Plane
2222

2323
enum class BoolType
2424
{
25-
FALSE = 0,
26-
TRUE = 1,
25+
IS_FALSE = 0,
26+
IS_TRUE = 1,
2727
UNKNOWN = 2
2828
};
2929

Library/Basestation.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222
#include "Message.h"
2323
#include "Stream.h"
2424

25-
#include "JSON/JSON.h"
26-
#include "JSON/Parser.h"
27-
#include "JSON/StringBuilder.h"
25+
#include "Utilities.h"
2826
#include "Keys.h"
2927
#include "ADSB.h"
3028

@@ -82,10 +80,8 @@ class Basestation : public SimpleStreamInOut<RAW, Plane::ADSB>
8280
// Timestamps (Fields 7-10)
8381
if (!fields[6].empty() && !fields[7].empty())
8482
{
85-
struct tm tm = {};
8683
std::string datetime = fields[6] + " " + fields[7];
87-
strptime(datetime.c_str(), "%Y/%m/%d %H:%M:%S", &tm);
88-
msg.setRxTimeUnix(mktime(&tm));
84+
msg.setRxTimeUnix(Util::Parse::DateTime(datetime));
8985
}
9086

9187
// Callsign (Field 10)

Library/Utilities.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818
#include <iomanip>
19+
#include <string>
1920

2021
#ifdef _WIN32
2122
#include <windows.h>
@@ -106,8 +107,6 @@ namespace Util
106107
return number;
107108
}
108109

109-
#include <string>
110-
111110
void Parse::URL(const std::string &url, std::string &protocol, std::string &username, std::string &password, std::string &host, std::string &port, std::string &path)
112111
{
113112
std::string s = url;
@@ -381,6 +380,25 @@ namespace Util
381380
}
382381
}
383382

383+
#ifdef _WIN32
384+
std::time_t Parse::DateTime(const std::string &datetime)
385+
{
386+
std::tm tm = {};
387+
std::istringstream ss(datetime);
388+
ss >> std::get_time(&tm, "%Y/%m/%d %H:%M:%S");
389+
if (ss.fail())
390+
return 0;
391+
return _mkgmtime(&tm);
392+
}
393+
#else
394+
std::time_t Parse::DateTime(const std::string &datetime)
395+
{
396+
std::tm tm = {};
397+
strptime(datetime.c_str(), "%Y/%m/%d %H:%M:%S", &tm);
398+
return timegm(&tm);
399+
}
400+
#endif
401+
384402
bool Parse::Switch(std::string arg, const std::string &TrueString, const std::string &FalseString)
385403
{
386404
Util::Convert::toUpper(arg);

Library/Utilities.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ namespace Util
142142
static bool Protocol(std::string str, PROTOCOL &protocol);
143143
static bool OutputFormat(std::string str, MessageFormat &out);
144144
static std::string DeviceTypeString(Type type);
145-
145+
static std::time_t DateTime(const std::string& datetime);
146146
static bool Switch(std::string arg, const std::string &TrueString = "ON", const std::string &FalseString = "OFF");
147147
static bool AutoInteger(std::string arg, int min, int max, int &val);
148148
static bool AutoFloat(std::string arg, double min, double max, double &val);

msvc/AIS-catcher RTLSDR.vcxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
<ClCompile Include="..\Library\Message.cpp" />
5858
<ClCompile Include="..\Library\JSONAIS.cpp" />
5959
<ClCompile Include="..\Library\NMEA.cpp" />
60+
<ClCompile Include="..\Library\Basestation.cpp" />
6061
<ClCompile Include="..\Library\Logger.cpp" />
6162
<ClCompile Include="..\Library\TCP.cpp" />
6263
<ClCompile Include="..\Library\Utilities.cpp" />
@@ -111,6 +112,8 @@
111112
<ClInclude Include="..\Library\Stream.h" />
112113
<ClInclude Include="..\Library\NMEA.h" />
113114
<ClInclude Include="..\Library\TCP.h" />
115+
<ClInclude Include="..\Library\ADSB.h" />
116+
<ClInclude Include="..\Library\Basestation.h" />
114117
<ClInclude Include="..\Library\Logger.h" />
115118
<ClInclude Include="..\Library\Utilities.h" />
116119
<ClInclude Include="..\Protocol\Protocol.h" />

0 commit comments

Comments
 (0)