Skip to content

Commit

Permalink
Add local time support for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
oxidase committed Jun 2, 2017
1 parent 0e39320 commit 50d9c4b
Show file tree
Hide file tree
Showing 11 changed files with 278 additions and 49 deletions.
6 changes: 2 additions & 4 deletions cucumber.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
module.exports = {
default: '--strict --tags ~@stress --tags ~@todo --tags ~@conditionals --require features/support --require features/step_definitions',
default: '--strict --tags ~@stress --tags ~@todo --require features/support --require features/step_definitions',
verify: '--strict --tags ~@stress --tags ~@todo -f progress --require features/support --require features/step_definitions',
todo: '--strict --tags @todo --require features/support --require features/step_definitions',
all: '--strict --require features/support --require features/step_definitions',
mld: '--strict --tags ~@stress --tags ~@todo --tags ~@alternative --tags ~@matrix --tags ~@trip --tags --require features/support --require features/step_definitions -f progress',
conditionals: '--strict --tags @conditionals --require features/support --require features/step_definitions',
mld_conditionals: '--strict --tags @conditionals --require features/support --require features/step_definitions -f progress'
mld: '--strict --tags ~@stress --tags ~@todo --tags ~@alternative --tags ~@matrix --tags ~@trip --tags --require features/support --require features/step_definitions -f progress'
}
90 changes: 45 additions & 45 deletions features/car/conditional_restrictions.feature

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions src/util/timezones.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <string>
#include <unordered_map>

#include <time.h>

// Function loads time zone shape polygons, computes a zone local time for utc_time,
// creates a lookup R-tree and returns a lambda function that maps a point
// to the corresponding local time
Expand Down Expand Up @@ -86,9 +88,15 @@ void Timezoner::LoadLocalTimesRTree(rapidjson::Document &geojson, std::time_t ut
if (it == local_time_memo.end())
{
struct tm timeinfo;
#if defined(_WIN32)
_putenv_s("TZ", tzname);
_tzset();
localtime_s(&timeinfo, &utc_time);
#else
setenv("TZ", tzname, 1);
tzset();
localtime_r(&utc_time, &timeinfo);
#endif
it = local_time_memo.insert({tzname, timeinfo}).first;
}

Expand Down Expand Up @@ -158,6 +166,7 @@ boost::optional<struct tm> Timezoner::operator()(const point_t &point) const
if (boost::geometry::within(point, local_times[index].first))
return local_times[index].second;
}
return boost::none;
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions test/data/tz/win/dc.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "FeatureCollection",

"features": [
{ "type": "Feature", "properties": { "tzid": "EST+5EDT" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -77.22564697265625, 38.758366935612784 ], [ -77.22564697265625, 39.030919255760622 ], [ -76.8218994140625, 39.030919255760622 ], [ -76.8218994140625, 38.758366935612784 ], [ -77.22564697265625, 38.758366935612784 ] ] ] } }
]
}
13 changes: 13 additions & 0 deletions test/data/tz/win/guinea.geojson

Large diffs are not rendered by default.

195 changes: 195 additions & 0 deletions test/data/tz/win/liverpool.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"tzid": "GMT0BST"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-4.115297325087907,
54.52745749948722
],
[
-4.0344301,
54.479
],
[
-3.9654913,
54.292
],
[
-3.9921158,
54.219
],
[
-4.1294243,
54.062
],
[
-4.3969301,
53.905
],
[
-4.4945949,
53.869
],
[
-4.8076135,
53.845
],
[
-4.9658203125,
53.863090828317766
],
[
-4.9658203125,
54.35334454933009
],
[
-4.8948807,
54.392
],
[
-4.868376,
54.4339904
],
[
-4.542761329182349,
54.52745749948722
],
[
-4.115297325087907,
54.52745749948722
]
]
]
}
},
{
"type": "Feature",
"properties": {
"tzid": "Europe\\/London"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-4.9658203125,
52.99176453037065
],
[
-4.8118632,
53.085
],
[
-4.9658203125,
53.175318218576706
],
[
-4.9658203125,
53.42898022700984
],
[
-4.8911294,
53.532
],
[
-4.7808677,
53.595
],
[
-4.6646014,
53.621
],
[
-4.4026046,
53.634
],
[
-4.147566,
53.599
],
[
-4.0053089,
53.526
],
[
-3.8324713,
53.541
],
[
-3.6271987,
53.508
],
[
-3.4402166,
53.547
],
[
-3.4248294,
53.62
],
[
-3.3683406,
53.697
],
[
-3.3958062,
53.764
],
[
-3.3917274,
53.8697263
],
[
-3.5494708,
53.99
],
[
-3.605841,
54.079
],
[
-3.729297,
54.198
],
[
-3.7790165,
54.288
],
[
-3.9491542,
54.4245157
],
[
-4.115297325087907,
54.52745749948722
],
[
-2.13134765625,
54.52745749948722
],
[
-2.13134765625,
52.65639394198803
],
[
-4.9658203125,
52.65639394198803
],
[
-4.9658203125,
52.99176453037065
]
]
]
}
}
]
}
7 changes: 7 additions & 0 deletions test/data/tz/win/london.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "FeatureCollection",

"features": [
{ "type": "Feature", "properties": { "tzid": "GMT0BST" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -0.212860107421875, 51.468766318140872 ], [ -0.212860107421875, 51.573868997085803 ], [ -0.014076232910156, 51.573868997085803 ], [ -0.014076232910156, 51.468766318140872 ], [ -0.212860107421875, 51.468766318140872 ] ] ] } }
]
}

0 comments on commit 50d9c4b

Please sign in to comment.