GitHub PullRequestReviewCommentEvent at 2014-07-02 12:30:33
Repository: navitia
Actor: l-vincent-l
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/CanalTP/navitia/pulls/comments/14453837","id":14453837,"diff_hunk":"@@ -46,6 +46,113 @@ namespace ed{ namespace connectors {\n static int default_waiting_duration = 120;\n static int default_connection_duration = 120;\n \n+std::pair<std::string, boost::local_time::time_zone_ptr> TzHandler::get_tz(const std::string& tz_name) {\n+    if (! tz_name.empty()) {\n+        auto tz = tz_db.time_zone_from_region(tz_name);\n+        if (tz) {\n+            return {tz_name, tz};\n+        }\n+        LOG4CPLUS_INFO(log4cplus::Logger::getInstance(\"ed\"), \"cannot find \" << tz_name << \" in tz db\");\n+    }\n+    //we fetch the default dataset timezone\n+    return default_timezone;\n+}\n+\n+\n+/*\n+ * we need the list of dst periods over the years of the validity period\n+ *\n+ *                                  validity period\n+ *                              [-----------------------]\n+ *                        2013                                  2014\n+ *       <------------------------------------><-------------------------------------->\n+ *[           non DST   )[  DST    )[        non DST     )[   DST     )[     non DST          )\n+ *\n+ * We thus create a partition of the time with all period with the UTC offset\n+ *\n+ *       [    +7h       )[  +8h    )[       +7h          )[   +8h     )[      +7h     )\n+ */\n+std::vector<period_with_utc_shift> get_dst_periods(const boost::gregorian::date_period& validity_period, const boost::local_time::time_zone_ptr& tz) {\n+\n+    if (validity_period.is_null()) {\n+        LOG4CPLUS_WARN(log4cplus::Logger::getInstance(\"log\"), \"validity period is not valid\");\n+        return {};\n+    }\n+    std::vector<int> years;\n+    //we want to have all the overlapping year\n+    //so add each time 1 year and continue till the first day of the year is after the end of the period (cf gtfs_parser_test.boost_periods)\n+    for (boost::gregorian::year_iterator y_it(validity_period.begin()); boost::gregorian::date((*y_it).year(), 1, 1) < validity_period.end(); ++y_it) {\n+        years.push_back((*y_it).year());\n+    }\n+\n+    BOOST_ASSERT(! years.empty());\n+\n+    std::vector<period_with_utc_shift> res;\n+    for (int year: years) {\n+        if (! res.empty()) {\n+            //if res is not empty we add the additional period without the dst\n+            //from the previous end date to the beggining of the dst next year\n+            res.push_back({ {res.back().period.end(), tz->dst_local_start_time(year).date()},\n+                            tz->base_utc_offset() });\n+        } else {\n+            //for the first elt, we add a non dst\n+            auto first_day_of_year = boost::gregorian::date(year, 1, 1);\n+            if (tz->dst_local_start_time(year).date() != first_day_of_year) {\n+                res.push_back({ {first_day_of_year, tz->dst_local_start_time(year).date()},\n+                                tz->base_utc_offset() });\n+            }\n+        }\n+        res.push_back({ {tz->dst_local_start_time(year).date(), tz->dst_local_end_time(year).date()},\n+                        tz->base_utc_offset() + tz->dst_offset() });\n+    }\n+    //we add the last non DST period\n+    res.push_back({ {res.back().period.end(), boost::gregorian::date(years.back() + 1, 1, 1)},\n+                    tz->base_utc_offset() });\n+    return res;\n+}\n+\n+std::vector<period_with_utc_shift> split_over_dst(const boost::gregorian::date_period& validity_period, const boost::local_time::time_zone_ptr& tz) {","path":"source/ed/connectors/gtfs_parser.cpp","position":69,"original_position":69,"commit_id":"3a85a9e453f6beece2ed5270e1da66b2e4a7124c","original_commit_id":"3a85a9e453f6beece2ed5270e1da66b2e4a7124c","user":{"login":"l-vincent-l","id":2757318,"avatar_url":"https://avatars.githubusercontent.com/u/2757318?","gravatar_id":"257c713557629d5e2948229fc146f387","url":"https://api.github.com/users/l-vincent-l","html_url":"https://github.com/l-vincent-l","followers_url":"https://api.github.com/users/l-vincent-l/followers","following_url":"https://api.github.com/users/l-vincent-l/following{/other_user}","gists_url":"https://api.github.com/users/l-vincent-l/gists{/gist_id}","starred_url":"https://api.github.com/users/l-vincent-l/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/l-vincent-l/subscriptions","organizations_url":"https://api.github.com/users/l-vincent-l/orgs","repos_url":"https://api.github.com/users/l-vincent-l/repos","events_url":"https://api.github.com/users/l-vincent-l/events{/privacy}","received_events_url":"https://api.github.com/users/l-vincent-l/received_events","type":"User","site_admin":false},"body":"ça serait pas mal de passer une ligne","created_at":"2014-07-02T12:30:33Z","updated_at":"2014-07-02T12:30:33Z","html_url":"https://github.com/CanalTP/navitia/pull/421#discussion_r14453837","pull_request_url":"https://api.github.com/repos/CanalTP/navitia/pulls/421","_links":{"self":{"href":"https://api.github.com/repos/CanalTP/navitia/pulls/comments/14453837"},"html":{"href":"https://github.com/CanalTP/navitia/pull/421#discussion_r14453837"},"pull_request":{"href":"https://api.github.com/repos/CanalTP/navitia/pulls/421"}}},"pull_request":{"url":"https://api.github.com/repos/CanalTP/navitia/pulls/421","id":17873606,"html_url":"https://github.com/CanalTP/navitia/pull/421","diff_url":"https://github.com/CanalTP/navitia/pull/421.diff","patch_url":"https://github.com/CanalTP/navitia/pull/421.patch","issue_url":"https://api.github.com/repos/CanalTP/navitia/issues/421","number":421,"state":"closed","title":"Time zone","user":{"login":"antoine-de","id":3987698,"avatar_url":"https://avatars.githubusercontent.com/u/3987698?","gravatar_id":"8dd8d4a02558295ff9429c91d8423286","url":"https://api.github.com/users/antoine-de","html_url":"https://github.com/antoine-de","followers_url":"https://api.github.com/users/antoine-de/followers","following_url":"https://api.github.com/users/antoine-de/following{/other_user}","gists_url":"https://api.github.com/users/antoine-de/gists{/gist_id}","starred_url":"https://api.github.com/users/antoine-de/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antoine-de/subscriptions","organizations_url":"https://api.github.com/users/antoine-de/orgs","repos_url":"https://api.github.com/users/antoine-de/repos","events_url":"https://api.github.com/users/antoine-de/events{/privacy}","received_events_url":"https://api.github.com/users/antoine-de/received_events","type":"User","site_admin":false},"body":"\r\n# DO NOT MERGE THIS PR, IT'S JUST FOR REVIEW FOR THE MOMENT\r\n\r\n## First PR for time zone handling\r\n\r\nThe main idea is to convert ALL times to UTC  in the import process, handle only UTC in kraken (the computation part) and change it to local time only at the end of the process in Jörmungandr (the middleware) using the added time zone info in each stop areas.\r\n\r\n\r\nThis PR handles the GTFS parser part.\r\n\r\nThe UTC conversion difficult part is day saving time (DST) handling.  \r\nFor example a stoptime at 7am valid over the year in a paris (Europe/Paris timezone) will be 6AM UTC in winter but 5AM UTC in summer.\r\n\r\nThus all validity_pattern (gtfs calendar), vehicule_journey (gtfs trips) and stoptime have to be split over the DST period.\r\n\r\n## Note\r\ndespite all its flaws we use boost::date_time for timzeone handling.\r\nfor the moment the boost csv is hardlinked in the project, but it will change.\r\n\r\n\r\n\r\n","created_at":"2014-07-02T08:38:52Z","updated_at":"2014-07-02T12:30:33Z","closed_at":"2014-07-02T11:58:31Z","merged_at":null,"merge_commit_sha":"bc67926908ac63094b2418123f6fa995f8d7d62b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CanalTP/navitia/pulls/421/commits","review_comments_url":"https://api.github.com/repos/CanalTP/navitia/pulls/421/comments","review_comment_url":"https://api.github.com/repos/CanalTP/navitia/pulls/comments/{number}","comments_url":"https://api.github.com/repos/CanalTP/navitia/issues/421/comments","statuses_url":"https://api.github.com/repos/CanalTP/navitia/statuses/3a85a9e453f6beece2ed5270e1da66b2e4a7124c","head":{"label":"antoine-de:time_zone","ref":"time_zone","sha":"3a85a9e453f6beece2ed5270e1da66b2e4a7124c","user":{"login":"antoine-de","id":3987698,"avatar_url":"https://avatars.githubusercontent.com/u/3987698?","gravatar_id":"8dd8d4a02558295ff9429c91d8423286","url":"https://api.github.com/users/antoine-de","html_url":"https://github.com/antoine-de","followers_url":"https://api.github.com/users/antoine-de/followers","following_url":"https://api.github.com/users/antoine-de/following{/other_user}","gists_url":"https://api.github.com/users/antoine-de/gists{/gist_id}","starred_url":"https://api.github.com/users/antoine-de/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antoine-de/subscriptions","organizations_url":"https://api.github.com/users/antoine-de/orgs","repos_url":"https://api.github.com/users/antoine-de/repos","events_url":"https://api.github.com/users/antoine-de/events{/privacy}","received_events_url":"https://api.github.com/users/antoine-de/received_events","type":"User","site_admin":false},"repo":{"id":19144843,"name":"navitia","full_name":"antoine-de/navitia","owner":{"login":"antoine-de","id":3987698,"avatar_url":"https://avatars.githubusercontent.com/u/3987698?","gravatar_id":"8dd8d4a02558295ff9429c91d8423286","url":"https://api.github.com/users/antoine-de","html_url":"https://github.com/antoine-de","followers_url":"https://api.github.com/users/antoine-de/followers","following_url":"https://api.github.com/users/antoine-de/following{/other_user}","gists_url":"https://api.github.com/users/antoine-de/gists{/gist_id}","starred_url":"https://api.github.com/users/antoine-de/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antoine-de/subscriptions","organizations_url":"https://api.github.com/users/antoine-de/orgs","repos_url":"https://api.github.com/users/antoine-de/repos","events_url":"https://api.github.com/users/antoine-de/events{/privacy}","received_events_url":"https://api.github.com/users/antoine-de/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/antoine-de/navitia","description":"","fork":true,"url":"https://api.github.com/repos/antoine-de/navitia","forks_url":"https://api.github.com/repos/antoine-de/navitia/forks","keys_url":"https://api.github.com/repos/antoine-de/navitia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/antoine-de/navitia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/antoine-de/navitia/teams","hooks_url":"https://api.github.com/repos/antoine-de/navitia/hooks","issue_events_url":"https://api.github.com/repos/antoine-de/navitia/issues/events{/number}","events_url":"https://api.github.com/repos/antoine-de/navitia/events","assignees_url":"https://api.github.com/repos/antoine-de/navitia/assignees{/user}","branches_url":"https://api.github.com/repos/antoine-de/navitia/branches{/branch}","tags_url":"https://api.github.com/repos/antoine-de/navitia/tags","blobs_url":"https://api.github.com/repos/antoine-de/navitia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/antoine-de/navitia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/antoine-de/navitia/git/refs{/sha}","trees_url":"https://api.github.com/repos/antoine-de/navitia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/antoine-de/navitia/statuses/{sha}","languages_url":"https://api.github.com/repos/antoine-de/navitia/languages","stargazers_url":"https://api.github.com/repos/antoine-de/navitia/stargazers","contributors_url":"https://api.github.com/repos/antoine-de/navitia/contributors","subscribers_url":"https://api.github.com/repos/antoine-de/navitia/subscribers","subscription_url":"https://api.github.com/repos/antoine-de/navitia/subscription","commits_url":"https://api.github.com/repos/antoine-de/navitia/commits{/sha}","git_commits_url":"https://api.github.com/repos/antoine-de/navitia/git/commits{/sha}","comments_url":"https://api.github.com/repos/antoine-de/navitia/comments{/number}","issue_comment_url":"https://api.github.com/repos/antoine-de/navitia/issues/comments/{number}","contents_url":"https://api.github.com/repos/antoine-de/navitia/contents/{+path}","compare_url":"https://api.github.com/repos/antoine-de/navitia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/antoine-de/navitia/merges","archive_url":"https://api.github.com/repos/antoine-de/navitia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/antoine-de/navitia/downloads","issues_url":"https://api.github.com/repos/antoine-de/navitia/issues{/number}","pulls_url":"https://api.github.com/repos/antoine-de/navitia/pulls{/number}","milestones_url":"https://api.github.com/repos/antoine-de/navitia/milestones{/number}","notifications_url":"https://api.github.com/repos/antoine-de/navitia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/antoine-de/navitia/labels{/name}","releases_url":"https://api.github.com/repos/antoine-de/navitia/releases{/id}","created_at":"2014-04-25T12:12:04Z","updated_at":"2014-06-26T15:12:00Z","pushed_at":"2014-07-02T08:58:42Z","git_url":"git://github.com/antoine-de/navitia.git","ssh_url":"git@github.com:antoine-de/navitia.git","clone_url":"https://github.com/antoine-de/navitia.git","svn_url":"https://github.com/antoine-de/navitia","homepage":"http://www.navitia.io/","size":19090,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"dev"}},"base":{"label":"CanalTP:dev","ref":"dev","sha":"99f70a0f0bbcf61794e46b71eb4ff12a323585cd","user":{"login":"CanalTP","id":2743985,"avatar_url":"https://avatars.githubusercontent.com/u/2743985?","gravatar_id":null,"url":"https://api.github.com/users/CanalTP","html_url":"https://github.com/CanalTP","followers_url":"https://api.github.com/users/CanalTP/followers","following_url":"https://api.github.com/users/CanalTP/following{/other_user}","gists_url":"https://api.github.com/users/CanalTP/gists{/gist_id}","starred_url":"https://api.github.com/users/CanalTP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CanalTP/subscriptions","organizations_url":"https://api.github.com/users/CanalTP/orgs","repos_url":"https://api.github.com/users/CanalTP/repos","events_url":"https://api.github.com/users/CanalTP/events{/privacy}","received_events_url":"https://api.github.com/users/CanalTP/received_events","type":"Organization","site_admin":false},"repo":{"id":10797333,"name":"navitia","full_name":"CanalTP/navitia","owner":{"login":"CanalTP","id":2743985,"avatar_url":"https://avatars.githubusercontent.com/u/2743985?","gravatar_id":null,"url":"https://api.github.com/users/CanalTP","html_url":"https://github.com/CanalTP","followers_url":"https://api.github.com/users/CanalTP/followers","following_url":"https://api.github.com/users/CanalTP/following{/other_user}","gists_url":"https://api.github.com/users/CanalTP/gists{/gist_id}","starred_url":"https://api.github.com/users/CanalTP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CanalTP/subscriptions","organizations_url":"https://api.github.com/users/CanalTP/orgs","repos_url":"https://api.github.com/users/CanalTP/repos","events_url":"https://api.github.com/users/CanalTP/events{/privacy}","received_events_url":"https://api.github.com/users/CanalTP/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CanalTP/navitia","description":"The REST API to build cool stuff with public transport","fork":false,"url":"https://api.github.com/repos/CanalTP/navitia","forks_url":"https://api.github.com/repos/CanalTP/navitia/forks","keys_url":"https://api.github.com/repos/CanalTP/navitia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CanalTP/navitia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CanalTP/navitia/teams","hooks_url":"https://api.github.com/repos/CanalTP/navitia/hooks","issue_events_url":"https://api.github.com/repos/CanalTP/navitia/issues/events{/number}","events_url":"https://api.github.com/repos/CanalTP/navitia/events","assignees_url":"https://api.github.com/repos/CanalTP/navitia/assignees{/user}","branches_url":"https://api.github.com/repos/CanalTP/navitia/branches{/branch}","tags_url":"https://api.github.com/repos/CanalTP/navitia/tags","blobs_url":"https://api.github.com/repos/CanalTP/navitia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CanalTP/navitia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CanalTP/navitia/git/refs{/sha}","trees_url":"https://api.github.com/repos/CanalTP/navitia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CanalTP/navitia/statuses/{sha}","languages_url":"https://api.github.com/repos/CanalTP/navitia/languages","stargazers_url":"https://api.github.com/repos/CanalTP/navitia/stargazers","contributors_url":"https://api.github.com/repos/CanalTP/navitia/contributors","subscribers_url":"https://api.github.com/repos/CanalTP/navitia/subscribers","subscription_url":"https://api.github.com/repos/CanalTP/navitia/subscription","commits_url":"https://api.github.com/repos/CanalTP/navitia/commits{/sha}","git_commits_url":"https://api.github.com/repos/CanalTP/navitia/git/commits{/sha}","comments_url":"https://api.github.com/repos/CanalTP/navitia/comments{/number}","issue_comment_url":"https://api.github.com/repos/CanalTP/navitia/issues/comments/{number}","contents_url":"https://api.github.com/repos/CanalTP/navitia/contents/{+path}","compare_url":"https://api.github.com/repos/CanalTP/navitia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CanalTP/navitia/merges","archive_url":"https://api.github.com/repos/CanalTP/navitia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CanalTP/navitia/downloads","issues_url":"https://api.github.com/repos/CanalTP/navitia/issues{/number}","pulls_url":"https://api.github.com/repos/CanalTP/navitia/pulls{/number}","milestones_url":"https://api.github.com/repos/CanalTP/navitia/milestones{/number}","notifications_url":"https://api.github.com/repos/CanalTP/navitia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CanalTP/navitia/labels{/name}","releases_url":"https://api.github.com/repos/CanalTP/navitia/releases{/id}","created_at":"2013-06-19T15:34:30Z","updated_at":"2014-06-30T17:08:29Z","pushed_at":"2014-06-26T16:31:44Z","git_url":"git://github.com/CanalTP/navitia.git","ssh_url":"git@github.com:CanalTP/navitia.git","clone_url":"https://github.com/CanalTP/navitia.git","svn_url":"https://github.com/CanalTP/navitia","homepage":"http://www.navitia.io","size":29945,"stargazers_count":49,"watchers_count":49,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":14,"mirror_url":null,"open_issues_count":11,"forks":14,"open_issues":11,"watchers":49,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/CanalTP/navitia/pulls/421"},"html":{"href":"https://github.com/CanalTP/navitia/pull/421"},"issue":{"href":"https://api.github.com/repos/CanalTP/navitia/issues/421"},"comments":{"href":"https://api.github.com/repos/CanalTP/navitia/issues/421/comments"},"review_comments":{"href":"https://api.github.com/repos/CanalTP/navitia/pulls/421/comments"},"review_comment":{"href":"https://api.github.com/repos/CanalTP/navitia/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/CanalTP/navitia/pulls/421/commits"},"statuses":{"href":"https://api.github.com/repos/CanalTP/navitia/statuses/3a85a9e453f6beece2ed5270e1da66b2e4a7124c"}}}}