{"action":"created","comment":{"url":"https://api.github.com/repos/jarib/ffi-icu/pulls/comments/34342721","id":34342721,"diff_hunk":"@@ -0,0 +1,176 @@\n+\n+module ICU\n+  module TimeFormatting\n+    @default_options = {}\n+    \n+    def self.create(options = {})\n+      DateTimeFormatter.new(@default_options.merge(options))\n+    end\n+\n+    def self.clear_default_options\n+      @default_options.clear\n+    end\n+\n+    def self.set_default_options(options)\n+      @default_options.merge!(options)\n+    end\n+\n+    def self.format(dt, options = {})\n+      create(@default_options.merge(options)).format(dt)\n+    end\n+\n+    class BaseFormatter\n+\n+      def set_attributes(options)\n+        options.each { |key, value| Lib.unum_set_attribute(@f, key, value) }\n+        self\n+      end\n+\n+      private\n+\n+      def make_formatter(time_style, date_style, locale, time_zone_str)\n+        time_zone = nil\n+        d_len = 0\n+        if time_zone_str\n+          time_zone = UCharPointer.from_string(time_zone_str)\n+          d_len = time_zone_str.size\n+        else\n+          Lib.check_error { | error| \n+            i_len  = 150\n+            time_zone = UCharPointer.new(i_len)\n+            d_len = Lib.ucal_getDefaultTimeZone(time_zone, i_len, error) \n+          }\n+        end\n+        ptr = Lib.check_error { | error| Lib.udat_open(time_style, date_style, locale, time_zone, d_len, FFI::MemoryPointer.new(4), -1, error) }\n+        FFI::AutoPointer.new(ptr, Lib.method(:udat_close))\n+      end\n+    end\n+\n+    class DateTimeFormatter < BaseFormatter\n+      def initialize(options={})\n+        time_style = options[:time]   || :short\n+        date_style = options[:date]   || :short\n+        locale     = options[:locale] || 'C'\n+        tz_style   = options[:tz_style]\n+        time_zone  = options[:zone]\n+        @f = make_formatter(time_style, date_style, locale, time_zone)\n+        if tz_style\n+          f0 = get_date_format(true)\n+          f1 = update_tz_format(f0, tz_style)    \n+          if f1 != f0\n+            set_date_format(true, f1)\n+          end\n+        end\n+      end\n+      def parse(str)","path":"lib/ffi-icu/time_formatting.rb","position":65,"original_position":65,"commit_id":"63a49dd5c4213b1d05ec67b2670c190384f5b42d","original_commit_id":"63a49dd5c4213b1d05ec67b2670c190384f5b42d","user":{"login":"jarib","id":572,"avatar_url":"https://avatars.githubusercontent.com/u/572?v=3","gravatar_id":"","url":"https://api.github.com/users/jarib","html_url":"https://github.com/jarib","followers_url":"https://api.github.com/users/jarib/followers","following_url":"https://api.github.com/users/jarib/following{/other_user}","gists_url":"https://api.github.com/users/jarib/gists{/gist_id}","starred_url":"https://api.github.com/users/jarib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarib/subscriptions","organizations_url":"https://api.github.com/users/jarib/orgs","repos_url":"https://api.github.com/users/jarib/repos","events_url":"https://api.github.com/users/jarib/events{/privacy}","received_events_url":"https://api.github.com/users/jarib/received_events","type":"User","site_admin":false},"body":"Please add a blank line after the `end`.","created_at":"2015-07-10T10:15:16Z","updated_at":"2015-07-10T10:15:16Z","html_url":"https://github.com/jarib/ffi-icu/pull/20#discussion_r34342721","pull_request_url":"https://api.github.com/repos/jarib/ffi-icu/pulls/20","_links":{"self":{"href":"https://api.github.com/repos/jarib/ffi-icu/pulls/comments/34342721"},"html":{"href":"https://github.com/jarib/ffi-icu/pull/20#discussion_r34342721"},"pull_request":{"href":"https://api.github.com/repos/jarib/ffi-icu/pulls/20"}}},"pull_request":{"url":"https://api.github.com/repos/jarib/ffi-icu/pulls/20","id":39538184,"html_url":"https://github.com/jarib/ffi-icu/pull/20","diff_url":"https://github.com/jarib/ffi-icu/pull/20.diff","patch_url":"https://github.com/jarib/ffi-icu/pull/20.patch","issue_url":"https://api.github.com/repos/jarib/ffi-icu/issues/20","number":20,"state":"open","locked":false,"title":"add support for Time Formatting/Parsing","user":{"login":"marek-veber","id":1288002,"avatar_url":"https://avatars.githubusercontent.com/u/1288002?v=3","gravatar_id":"","url":"https://api.github.com/users/marek-veber","html_url":"https://github.com/marek-veber","followers_url":"https://api.github.com/users/marek-veber/followers","following_url":"https://api.github.com/users/marek-veber/following{/other_user}","gists_url":"https://api.github.com/users/marek-veber/gists{/gist_id}","starred_url":"https://api.github.com/users/marek-veber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marek-veber/subscriptions","organizations_url":"https://api.github.com/users/marek-veber/orgs","repos_url":"https://api.github.com/users/marek-veber/repos","events_url":"https://api.github.com/users/marek-veber/events{/privacy}","received_events_url":"https://api.github.com/users/marek-veber/received_events","type":"User","site_admin":false},"body":"Hi, I expect, that it's OK now.\r\n\r\nI'm prepared to push next two pull requests, if You will find it usefull:\r\n1) compatible changes to run on ruby1.8 and 1.9.1\r\n2) files need to build .deb package (works on wheezy with ruby1.8 and 1.9.1 and libicu48 and on jessie with ruby2.1 and libicu52)","created_at":"2015-07-09T00:37:56Z","updated_at":"2015-07-10T10:15:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f3b18a86376c33b2450d16de48eaec3c8afefab5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jarib/ffi-icu/pulls/20/commits","review_comments_url":"https://api.github.com/repos/jarib/ffi-icu/pulls/20/comments","review_comment_url":"https://api.github.com/repos/jarib/ffi-icu/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jarib/ffi-icu/issues/20/comments","statuses_url":"https://api.github.com/repos/jarib/ffi-icu/statuses/63a49dd5c4213b1d05ec67b2670c190384f5b42d","head":{"label":"marek-veber:time-formating","ref":"time-formating","sha":"63a49dd5c4213b1d05ec67b2670c190384f5b42d","user":{"login":"marek-veber","id":1288002,"avatar_url":"https://avatars.githubusercontent.com/u/1288002?v=3","gravatar_id":"","url":"https://api.github.com/users/marek-veber","html_url":"https://github.com/marek-veber","followers_url":"https://api.github.com/users/marek-veber/followers","following_url":"https://api.github.com/users/marek-veber/following{/other_user}","gists_url":"https://api.github.com/users/marek-veber/gists{/gist_id}","starred_url":"https://api.github.com/users/marek-veber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marek-veber/subscriptions","organizations_url":"https://api.github.com/users/marek-veber/orgs","repos_url":"https://api.github.com/users/marek-veber/repos","events_url":"https://api.github.com/users/marek-veber/events{/privacy}","received_events_url":"https://api.github.com/users/marek-veber/received_events","type":"User","site_admin":false},"repo":{"id":31313922,"name":"ffi-icu","full_name":"marek-veber/ffi-icu","owner":{"login":"marek-veber","id":1288002,"avatar_url":"https://avatars.githubusercontent.com/u/1288002?v=3","gravatar_id":"","url":"https://api.github.com/users/marek-veber","html_url":"https://github.com/marek-veber","followers_url":"https://api.github.com/users/marek-veber/followers","following_url":"https://api.github.com/users/marek-veber/following{/other_user}","gists_url":"https://api.github.com/users/marek-veber/gists{/gist_id}","starred_url":"https://api.github.com/users/marek-veber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marek-veber/subscriptions","organizations_url":"https://api.github.com/users/marek-veber/orgs","repos_url":"https://api.github.com/users/marek-veber/repos","events_url":"https://api.github.com/users/marek-veber/events{/privacy}","received_events_url":"https://api.github.com/users/marek-veber/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/marek-veber/ffi-icu","description":"Simple FFI wrappers for things I need from ICU.","fork":true,"url":"https://api.github.com/repos/marek-veber/ffi-icu","forks_url":"https://api.github.com/repos/marek-veber/ffi-icu/forks","keys_url":"https://api.github.com/repos/marek-veber/ffi-icu/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marek-veber/ffi-icu/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marek-veber/ffi-icu/teams","hooks_url":"https://api.github.com/repos/marek-veber/ffi-icu/hooks","issue_events_url":"https://api.github.com/repos/marek-veber/ffi-icu/issues/events{/number}","events_url":"https://api.github.com/repos/marek-veber/ffi-icu/events","assignees_url":"https://api.github.com/repos/marek-veber/ffi-icu/assignees{/user}","branches_url":"https://api.github.com/repos/marek-veber/ffi-icu/branches{/branch}","tags_url":"https://api.github.com/repos/marek-veber/ffi-icu/tags","blobs_url":"https://api.github.com/repos/marek-veber/ffi-icu/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marek-veber/ffi-icu/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marek-veber/ffi-icu/git/refs{/sha}","trees_url":"https://api.github.com/repos/marek-veber/ffi-icu/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marek-veber/ffi-icu/statuses/{sha}","languages_url":"https://api.github.com/repos/marek-veber/ffi-icu/languages","stargazers_url":"https://api.github.com/repos/marek-veber/ffi-icu/stargazers","contributors_url":"https://api.github.com/repos/marek-veber/ffi-icu/contributors","subscribers_url":"https://api.github.com/repos/marek-veber/ffi-icu/subscribers","subscription_url":"https://api.github.com/repos/marek-veber/ffi-icu/subscription","commits_url":"https://api.github.com/repos/marek-veber/ffi-icu/commits{/sha}","git_commits_url":"https://api.github.com/repos/marek-veber/ffi-icu/git/commits{/sha}","comments_url":"https://api.github.com/repos/marek-veber/ffi-icu/comments{/number}","issue_comment_url":"https://api.github.com/repos/marek-veber/ffi-icu/issues/comments{/number}","contents_url":"https://api.github.com/repos/marek-veber/ffi-icu/contents/{+path}","compare_url":"https://api.github.com/repos/marek-veber/ffi-icu/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marek-veber/ffi-icu/merges","archive_url":"https://api.github.com/repos/marek-veber/ffi-icu/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marek-veber/ffi-icu/downloads","issues_url":"https://api.github.com/repos/marek-veber/ffi-icu/issues{/number}","pulls_url":"https://api.github.com/repos/marek-veber/ffi-icu/pulls{/number}","milestones_url":"https://api.github.com/repos/marek-veber/ffi-icu/milestones{/number}","notifications_url":"https://api.github.com/repos/marek-veber/ffi-icu/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marek-veber/ffi-icu/labels{/name}","releases_url":"https://api.github.com/repos/marek-veber/ffi-icu/releases{/id}","created_at":"2015-02-25T13:07:51Z","updated_at":"2015-04-16T16:44:37Z","pushed_at":"2015-07-09T22:00:47Z","git_url":"git://github.com/marek-veber/ffi-icu.git","ssh_url":"git@github.com:marek-veber/ffi-icu.git","clone_url":"https://github.com/marek-veber/ffi-icu.git","svn_url":"https://github.com/marek-veber/ffi-icu","homepage":"http://site.icu-project.org/","size":290,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"jarib:master","ref":"master","sha":"281eaa2101fef7070ad83d8f2a9808bb07ca8ba5","user":{"login":"jarib","id":572,"avatar_url":"https://avatars.githubusercontent.com/u/572?v=3","gravatar_id":"","url":"https://api.github.com/users/jarib","html_url":"https://github.com/jarib","followers_url":"https://api.github.com/users/jarib/followers","following_url":"https://api.github.com/users/jarib/following{/other_user}","gists_url":"https://api.github.com/users/jarib/gists{/gist_id}","starred_url":"https://api.github.com/users/jarib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarib/subscriptions","organizations_url":"https://api.github.com/users/jarib/orgs","repos_url":"https://api.github.com/users/jarib/repos","events_url":"https://api.github.com/users/jarib/events{/privacy}","received_events_url":"https://api.github.com/users/jarib/received_events","type":"User","site_admin":false},"repo":{"id":657870,"name":"ffi-icu","full_name":"jarib/ffi-icu","owner":{"login":"jarib","id":572,"avatar_url":"https://avatars.githubusercontent.com/u/572?v=3","gravatar_id":"","url":"https://api.github.com/users/jarib","html_url":"https://github.com/jarib","followers_url":"https://api.github.com/users/jarib/followers","following_url":"https://api.github.com/users/jarib/following{/other_user}","gists_url":"https://api.github.com/users/jarib/gists{/gist_id}","starred_url":"https://api.github.com/users/jarib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarib/subscriptions","organizations_url":"https://api.github.com/users/jarib/orgs","repos_url":"https://api.github.com/users/jarib/repos","events_url":"https://api.github.com/users/jarib/events{/privacy}","received_events_url":"https://api.github.com/users/jarib/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jarib/ffi-icu","description":"Simple FFI wrappers for things I need from ICU.","fork":false,"url":"https://api.github.com/repos/jarib/ffi-icu","forks_url":"https://api.github.com/repos/jarib/ffi-icu/forks","keys_url":"https://api.github.com/repos/jarib/ffi-icu/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jarib/ffi-icu/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jarib/ffi-icu/teams","hooks_url":"https://api.github.com/repos/jarib/ffi-icu/hooks","issue_events_url":"https://api.github.com/repos/jarib/ffi-icu/issues/events{/number}","events_url":"https://api.github.com/repos/jarib/ffi-icu/events","assignees_url":"https://api.github.com/repos/jarib/ffi-icu/assignees{/user}","branches_url":"https://api.github.com/repos/jarib/ffi-icu/branches{/branch}","tags_url":"https://api.github.com/repos/jarib/ffi-icu/tags","blobs_url":"https://api.github.com/repos/jarib/ffi-icu/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jarib/ffi-icu/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jarib/ffi-icu/git/refs{/sha}","trees_url":"https://api.github.com/repos/jarib/ffi-icu/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jarib/ffi-icu/statuses/{sha}","languages_url":"https://api.github.com/repos/jarib/ffi-icu/languages","stargazers_url":"https://api.github.com/repos/jarib/ffi-icu/stargazers","contributors_url":"https://api.github.com/repos/jarib/ffi-icu/contributors","subscribers_url":"https://api.github.com/repos/jarib/ffi-icu/subscribers","subscription_url":"https://api.github.com/repos/jarib/ffi-icu/subscription","commits_url":"https://api.github.com/repos/jarib/ffi-icu/commits{/sha}","git_commits_url":"https://api.github.com/repos/jarib/ffi-icu/git/commits{/sha}","comments_url":"https://api.github.com/repos/jarib/ffi-icu/comments{/number}","issue_comment_url":"https://api.github.com/repos/jarib/ffi-icu/issues/comments{/number}","contents_url":"https://api.github.com/repos/jarib/ffi-icu/contents/{+path}","compare_url":"https://api.github.com/repos/jarib/ffi-icu/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jarib/ffi-icu/merges","archive_url":"https://api.github.com/repos/jarib/ffi-icu/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jarib/ffi-icu/downloads","issues_url":"https://api.github.com/repos/jarib/ffi-icu/issues{/number}","pulls_url":"https://api.github.com/repos/jarib/ffi-icu/pulls{/number}","milestones_url":"https://api.github.com/repos/jarib/ffi-icu/milestones{/number}","notifications_url":"https://api.github.com/repos/jarib/ffi-icu/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jarib/ffi-icu/labels{/name}","releases_url":"https://api.github.com/repos/jarib/ffi-icu/releases{/id}","created_at":"2010-05-09T17:42:00Z","updated_at":"2015-04-09T07:37:27Z","pushed_at":"2015-07-09T22:00:48Z","git_url":"git://github.com/jarib/ffi-icu.git","ssh_url":"git@github.com:jarib/ffi-icu.git","clone_url":"https://github.com/jarib/ffi-icu.git","svn_url":"https://github.com/jarib/ffi-icu","homepage":"http://site.icu-project.org/","size":391,"stargazers_count":21,"watchers_count":21,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":2,"forks":10,"open_issues":2,"watchers":21,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jarib/ffi-icu/pulls/20"},"html":{"href":"https://github.com/jarib/ffi-icu/pull/20"},"issue":{"href":"https://api.github.com/repos/jarib/ffi-icu/issues/20"},"comments":{"href":"https://api.github.com/repos/jarib/ffi-icu/issues/20/comments"},"review_comments":{"href":"https://api.github.com/repos/jarib/ffi-icu/pulls/20/comments"},"review_comment":{"href":"https://api.github.com/repos/jarib/ffi-icu/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jarib/ffi-icu/pulls/20/commits"},"statuses":{"href":"https://api.github.com/repos/jarib/ffi-icu/statuses/63a49dd5c4213b1d05ec67b2670c190384f5b42d"}}}}