{"action":"created","issue":{"url":"https://api.github.com/repos/irobayna/stupidedi/issues/121","repository_url":"https://api.github.com/repos/irobayna/stupidedi","labels_url":"https://api.github.com/repos/irobayna/stupidedi/issues/121/labels{/name}","comments_url":"https://api.github.com/repos/irobayna/stupidedi/issues/121/comments","events_url":"https://api.github.com/repos/irobayna/stupidedi/issues/121/events","html_url":"https://github.com/irobayna/stupidedi/issues/121","id":314266145,"number":121,"title":"Unable to read the time field G62","user":{"login":"rdudacz","id":3080919,"avatar_url":"https://avatars1.githubusercontent.com/u/3080919?v=4","gravatar_id":"","url":"https://api.github.com/users/rdudacz","html_url":"https://github.com/rdudacz","followers_url":"https://api.github.com/users/rdudacz/followers","following_url":"https://api.github.com/users/rdudacz/following{/other_user}","gists_url":"https://api.github.com/users/rdudacz/gists{/gist_id}","starred_url":"https://api.github.com/users/rdudacz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rdudacz/subscriptions","organizations_url":"https://api.github.com/users/rdudacz/orgs","repos_url":"https://api.github.com/users/rdudacz/repos","events_url":"https://api.github.com/users/rdudacz/events{/privacy}","received_events_url":"https://api.github.com/users/rdudacz/received_events","type":"User","site_admin":false},"labels":[{"id":901264194,"url":"https://api.github.com/repos/irobayna/stupidedi/labels/QUESTION","name":"QUESTION","color":"fbffaf","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-04-13T22:18:25Z","updated_at":"2018-04-14T15:31:54Z","closed_at":null,"author_association":"NONE","body":"Hello,\r\n\r\nI am facing a problem when I have a segment with a date and time field and when attempting to read it, I get this error message:\r\n\r\n```\r\n/Users/adam/.rvm/gems/ruby-2.3.3/gems/stupidedi-1.2.15/lib/stupidedi/either.rb:154:in `deconstruct': undefined method `value' for \"\\e[30mTM.value\\e[2m\\e[37m[ E337: Time]\\e[0m\\e[0m\\e[0m(11:00:ss)\":Stupidedi::Versions::FunctionalGroups::FortyTen::ElementTypes::TimeVal::NonEmpty (NoMethodError)\r\n\tfrom /Users/adam/.rvm/gems/ruby-2.3.3/gems/stupidedi-1.2.15/lib/stupidedi/either.rb:99:in `map'\r\n\tfrom test_stupidedi.rb:42:in `block in el'\r\n\tfrom test_stupidedi.rb:42:in `map'\r\n\tfrom test_stupidedi.rb:42:in `el'\r\n\tfrom test_stupidedi.rb:86:in `block in <main>'\r\n\tfrom /Users/adam/.rvm/gems/ruby-2.3.3/gems/stupidedi-1.2.15/lib/stupidedi/either.rb:154:in `deconstruct'\r\n\tfrom /Users/adam/.rvm/gems/ruby-2.3.3/gems/stupidedi-1.2.15/lib/stupidedi/either.rb:129:in `tap'\r\n\tfrom test_stupidedi.rb:86:in `<main>'\r\n```\r\n\r\nHere's a sample of the file:\r\n```\r\nISA*00*          *00*          *ZZ*HELLO       *02*ABCD           *180406*1536*U*00401*000000002*0*T*>~\r\nGS*SM*7086462438*HELLO*20180406*1536*2*X*004010~\r\nST*204*0002~\r\nB2**TSVL**2022081140*L*PP*L~\r\nB2A*00~\r\nG62*64*20160527*1*1100*LT~\r\n```\r\n\r\nHere's the config:\r\n```\r\nconfig = Stupidedi::Config.contrib\r\nparser = Stupidedi::Builder::StateMachine.build(config)\r\n```\r\n\r\nWhat am I doing wrong and cannot successfully obtain these fields? I checked the documentation and the format of the file (and the segment) seems to be correct.\r\n\r\nThank you in advance."},"comment":{"url":"https://api.github.com/repos/irobayna/stupidedi/issues/comments/381337279","html_url":"https://github.com/irobayna/stupidedi/issues/121#issuecomment-381337279","issue_url":"https://api.github.com/repos/irobayna/stupidedi/issues/121","id":381337279,"user":{"login":"irobayna","id":349175,"avatar_url":"https://avatars3.githubusercontent.com/u/349175?v=4","gravatar_id":"","url":"https://api.github.com/users/irobayna","html_url":"https://github.com/irobayna","followers_url":"https://api.github.com/users/irobayna/followers","following_url":"https://api.github.com/users/irobayna/following{/other_user}","gists_url":"https://api.github.com/users/irobayna/gists{/gist_id}","starred_url":"https://api.github.com/users/irobayna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/irobayna/subscriptions","organizations_url":"https://api.github.com/users/irobayna/orgs","repos_url":"https://api.github.com/users/irobayna/repos","events_url":"https://api.github.com/users/irobayna/events{/privacy}","received_events_url":"https://api.github.com/users/irobayna/received_events","type":"User","site_admin":false},"created_at":"2018-04-14T15:31:54Z","updated_at":"2018-04-14T15:31:54Z","author_association":"OWNER","body":"@rdudacz Are you parsing the tree?\r\n\r\nHere is some code that might help you:\r\n\r\n```ruby\r\nconfig = Stupidedi::Config.contrib\r\nparser = Stupidedi::Builder::StateMachine.build(config)\r\ninput  = File.open(\"your file name here\")\r\nparser, result = parser.read(Stupidedi::Reader.build(input))\r\n\r\n# Then traverse the tree 'parser'\r\n parser.first.tap do |isa|\r\n\r\n        ## this is how you would get individual elements\r\n\r\n        sender_id    = \"#{isa.element(6).map(&:node).fetch(0)}\"\r\n        receiver_id  = \"#{isa.element(8).map(&:node).fetch(0)}\"\r\n        current_date = \"#{isa.element(9).map(&:node).fetch(0)}\"\r\n        current_time = \"#{isa.element(10).map(&:node).fetch(0)}\"\r\n        isa_ctrl_no  = \"#{isa.element(13).map(&:node).fetch(0)}\"\r\n\r\n        isa.iterate(:GS) do |gs|\r\n          group_ctrl_no = \"#{gs.element(6).map(&:node).fetch(0)}\"\r\n          create_date = Interchangeable.parse_edi_date(\"#{gs.element(4).map(&:node).fetch(0)}\")\r\n\r\n          gs.iterate(:ST) do |st|\r\n           st.find(:BFR).map do |bfr|\r\n             transaction_set_purpose_code = \"#{bfr.element(1).map(&:node).fetch(0)}\"\r\n```\r\n\r\nIn regards to the date, you should format it accordingly to your EDI guidelines.  I have a few helper methods that I use on my own code to help with the date / time parsing:  \r\n\r\n```Interchangeable.parse_edi_Date()```\r\n\r\n```ruby\r\ndef self.parse_edi_date(edi_date)\r\n\r\n    if edi_date[0] == 'X'\r\n      # XXYYMMDD\r\n      Time.strptime(\"#{edi_date}\", 'XX%y%m%d')\r\n    else\r\n      # YYYY-MM-DD\r\n      Time.strptime(\"#{edi_date}\", '%Y-%m-%d')\r\n    end\r\n  end\r\n```\r\n\r\n"}}
{"actor":{"display_login":"irobayna"}}