Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentError: "+HH:MM" or "-HH:MM" expected for utc_offset #2310

Closed
dalizard opened this issue Dec 12, 2014 · 11 comments
Closed

ArgumentError: "+HH:MM" or "-HH:MM" expected for utc_offset #2310

dalizard opened this issue Dec 12, 2014 · 11 comments
Assignees
Labels
Milestone

Comments

@dalizard
Copy link

Hello!

I am not 100% if this needs to be handled by JRuby or ActiveSupport, but here is the problem.

[1] pry(main)> `ruby -v`
=> "ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]\n"
[2] pry(main)> 1.hour.from_now.localtime

From: /Users/dimitar/Projects/List-It-Local/backend/.bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc2/lib/active_support/time_with_zone.rb @ line 79 Time#localtime:

    78: def localtime(utc_offset = nil)
 => 79:   binding.pry
    80:   utc.respond_to?(:getlocal) ? utc.getlocal(utc_offset) : utc.to_time.getlocal(utc_offset)
    81: end

[1] pry(#<ActiveSupport::TimeWithZone>)> utc_offset
=> nil
[2] pry(#<ActiveSupport::TimeWithZone>)> utc.respond_to?(:getlocal)
=> true
[3] pry(#<ActiveSupport::TimeWithZone>)> utc.getlocal(utc_offset)
=> 2014-12-12 18:53:45 +0200
[5] pry(#<ActiveSupport::TimeWithZone>)> `ruby -v`
=> "jruby 1.7.16.2 (2.0.0p195) 2014-12-08 365d573 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_71-b14 [darwin-x86_64]\n"
[6] pry(#<ActiveSupport::TimeWithZone>)> 1.hour.from_now.localtime

From: /Users/dimitar/Projects/Secret/app/user_service/vendor/jruby/1.9/gems/activesupport-4.2.0.rc2/lib/active_support/time_with_zone.rb @ line 79 Time#localtime:

    78: def localtime(utc_offset = nil)
 => 79:   binding.pry
    80:   utc.respond_to?(:getlocal) ? utc.getlocal(utc_offset) : utc.to_time.getlocal(utc_offset)
    81: end

[1] pry(#<ActiveSupport::TimeWithZone>)> utc_offset
=> nil
[2] pry(#<ActiveSupport::TimeWithZone>)> utc.respond_to?(:getlocal)
=> true
[3] pry(#<ActiveSupport::TimeWithZone>)> utc.getlocal(utc_offset)
ArgumentError: "+HH:MM" or "-HH:MM" expected for utc_offset
from org/jruby/RubyTime.java:442:in `getlocal'

The problem basically is coming from the fact that MRI handles nil cases of the passed utc_offset parameter, while JRuby does not. What do you think should be the proper behaviour here?

@enebo enebo added this to the JRuby 1.7.18 milestone Dec 12, 2014
@enebo
Copy link
Member

enebo commented Dec 12, 2014

Confirmed on jruby-1_7 and master:

Time.now.getlocal(nil)

1.9+ compatibility

evanphx pushed a commit to ruby/ruby that referenced this issue Dec 15, 2014
  jruby/jruby#2310.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
@headius
Copy link
Member

headius commented Dec 15, 2014

@headius headius added the core label Dec 15, 2014
@headius headius self-assigned this Dec 15, 2014
@dalizard
Copy link
Author

Thank you!

ayumin pushed a commit to ayumin/ruby that referenced this issue Jan 4, 2015
  jruby/jruby#2310.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
@mjansing
Copy link

mjansing commented Jan 7, 2015

I got a similar issue with JRuby 1.7.18:

[1] pry(main)> `ruby -v`
=> "jruby 1.7.18 (1.9.3p551) 2014-12-22 625381c on Java HotSpot(TM) 64-Bit Server VM 1.7.0_51-b13 [darwin-x86_64]\n"
[2] pry(main)> t = Time.zone.now
=> Wed, 07 Jan 2015 14:49:56 UTC +00:00
[3] pry(main)> I18n.l(t, :format => :short)
ArgumentError: "+HH:MM" or "-HH:MM" expected for utc_offset
from org/jruby/RubyTime.java:443:in `getlocal'

On MRI everything works fine:

[1] pry(main)> `ruby -v`
=> "ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]\n"
[2] pry(main)> t = Time.zone.now
=> Wed, 07 Jan 2015 14:56:05 UTC +00:00
[3] pry(main)> I18n.l(t, :format => :short)
=> "07 Jan 14:56"
[4] pry(main)>

@enebo
Copy link
Member

enebo commented Jan 7, 2015

@mjansing This is showing the same error but it is a different issue (nil as argument was this issue and this must be something other than nil or a valid string). Can you open this as a fresh issue? You get bonus points if you can trace through I18n to the actual argument to the getlocal call...

@dalizard
Copy link
Author

dalizard commented Jan 7, 2015

@enebo I debugged the problem a bit more, and opened a new issue since it's a different problem.

@enebo
Copy link
Member

enebo commented Jan 7, 2015

Curiousity got the better of me and I looked at MRI and then noticed we partially applied a fix to master. I commented on the issue you opened. Thanks @dalizard!

@mjansing
Copy link

mjansing commented Jan 8, 2015

@dalizard Thank you for digging into this issue.

@dalizard
Copy link
Author

dalizard commented Jan 8, 2015

@mjansing @enebo You're welcome!

@TheSynthMaster
Copy link

Updated to 1.7.18 but the problem when outputting dates is still there, in action view...

...
ActionView::Template::Error ("+HH:MM" or "-HH:MM" expected for utc_offset):
47: <%= link_to "#{h (get_config('TV-INCIDENT-FIELD')=='description' ? truncate(get_desc('assets',incident.asset.id) , :length=>30) : incident.asset.code)}" , edit_incident_path(incident) %>
48: <%= link_to "#{h (truncate(incident.description , :length=>40))}" , edit_incident_path(incident) %>
49: <%= link_to "#{h get_translation('incidents','status',incident.status)}" , edit_incident_path(incident) %>
50: <%= link_to "#{h eval("incident."+params[:which_date])}" , edit_incident_path(incident) %>
51:
52: <% end %>
53:


org/jruby/RubyTime.java:443:in getlocal' activesupport (4.2.0) lib/active_support/time_with_zone.rb:79:inlocaltime'
activesupport (4.2.0) lib/active_support/time_with_zone.rb:208:in strftime' activesupport (4.2.0) lib/active_support/time_with_zone.rb:197:into_s'
C:/jrails4_update/applications/assetsolutions/config/initializers/redefine_html_escape.rb:5:in html_escape' C:/jrails4_update/applications/assetsolutions/app/views/incidents/index.html.erb:50:in____jrails__update_applications_assetsolutions_app_views_incidents_index_html_erb___1360065077_10940'
org/jruby/RubyArray.java:1613:in each' C:0:ineach'
C:/jrails4_update/applications/assetsolutions/app/views/incidents/index.html.erb:44:in ____jrails__update_applications_assetsolutions_app_views_incidents_index_html_erb___1360065077_10940' actionview (4.2.0) lib/action_view/helpers/capture_helper.rb:38:incapture'
actionview (4.2.0) lib/action_view/helpers/capture_helper.rb:200:in with_output_buffer' actionview (4.2.0) lib/action_view/helpers/capture_helper.rb:38:incapture'
actionview (4.2.0) lib/action_view/helpers/form_tag_helper.rb:70:in form_tag' C:/jrails4_update/applications/assetsolutions/app/views/incidents/index.html.erb:4:in____jrails__update_applications_assetsolutions_app_views_incidents_index_html_erb___1360065077_10940'
actionview (4.2.0) lib/action_view/template.rb:145:in render' activesupport (4.2.0) lib/active_support/notifications.rb:166:ininstrument'
actionview (4.2.0) lib/action_view/template.rb:333:in instrument' actionview (4.2.0) lib/action_view/template.rb:143:inrender'
actionview (4.2.0) lib/action_view/renderer/template_renderer.rb:54:in render_template' actionview (4.2.0) lib/action_view/renderer/abstract_renderer.rb:39:ininstrument'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in instrument' activesupport (4.2.0) lib/active_support/notifications/instrumenter.rb:20:ininstrument'
activesupport (4.2.0) lib/active_support/notifications/instrumenter.rb:19:in instrument' activesupport (4.2.0) lib/active_support/notifications.rb:164:ininstrument'
actionview (4.2.0) lib/action_view/renderer/abstract_renderer.rb:39:in instrument' actionview (4.2.0) lib/action_view/renderer/template_renderer.rb:53:inrender_template'
actionview (4.2.0) lib/action_view/renderer/template_renderer.rb:61:in render_with_layout' actionview (4.2.0) lib/action_view/renderer/template_renderer.rb:52:inrender_template'
actionview (4.2.0) lib/action_view/renderer/template_renderer.rb:14:in render' actionview (4.2.0) lib/action_view/renderer/renderer.rb:42:inrender_template'
actionview (4.2.0) lib/action_view/renderer/renderer.rb:23:in render' actionview (4.2.0) lib/action_view/rendering.rb:100:in_render_template'
actionpack (4.2.0) lib/action_controller/metal/streaming.rb:217:in _render_template' actionview (4.2.0) lib/action_view/rendering.rb:83:inrender_to_body'
actionpack (4.2.0) lib/action_controller/metal/rendering.rb:32:in render_to_body' actionpack (4.2.0) lib/action_controller/metal/renderers.rb:37:inrender_to_body'
actionpack (4.2.0) lib/abstract_controller/rendering.rb:25:in render' actionpack (4.2.0) lib/action_controller/metal/rendering.rb:16:inrender'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:41:in render' activesupport (4.2.0) lib/active_support/core_ext/benchmark.rb:12:inms'
C:/jrails4_update/jruby/lib/ruby/1.9/benchmark.rb:295:in realtime' activesupport (4.2.0) lib/active_support/core_ext/benchmark.rb:12:inms'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:41:in render' actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:84:incleanup_view_runtime'
activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:25:in cleanup_view_runtime' actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:40:inrender'
actionpack (4.2.0) lib/action_controller/metal/mime_responds.rb:216:in respond_to' C:/jrails4_update/applications/assetsolutions/app/controllers/incidents_controller.rb:52:inindex'
actionpack (4.2.0) lib/action_controller/metal/implicit_render.rb:4:in send_action' actionpack (4.2.0) lib/abstract_controller/base.rb:198:inprocess_action'
actionpack (4.2.0) lib/action_controller/metal/rendering.rb:10:in process_action' actionpack (4.2.0) lib/abstract_controller/callbacks.rb:20:inprocess_action'
org/jruby/RubyProc.java:271:in call' activesupport (4.2.0) lib/active_support/callbacks.rb:117:incall'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in halting' org/jruby/RubyProc.java:271:incall'
activesupport (4.2.0) lib/active_support/callbacks.rb:219:in halting_and_conditional' org/jruby/RubyProc.java:271:incall'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in halting' org/jruby/RubyProc.java:271:incall'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in halting_and_conditional' org/jruby/RubyProc.java:271:incall'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in halting_and_conditional' org/jruby/RubyProc.java:271:incall'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in halting_and_conditional' org/jruby/RubyProc.java:271:incall'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in halting_and_conditional' org/jruby/RubyProc.java:271:incall'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in halting' org/jruby/RubyProc.java:271:incall'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in halting_and_conditional' org/jruby/RubyProc.java:271:incall'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in halting_and_conditional' org/jruby/RubyProc.java:271:incall'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in halting_and_conditional' org/jruby/RubyProc.java:271:incall'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in _run_callbacks' activesupport (4.2.0) lib/active_support/callbacks.rb:738:in_run_process_action_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (4.2.0) lib/abstract_controller/callbacks.rb:19:inprocess_action'
actionpack (4.2.0) lib/action_controller/metal/rescue.rb:29:in process_action' actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:31:inprocess_action'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in instrument' activesupport (4.2.0) lib/active_support/notifications/instrumenter.rb:20:ininstrument'
activesupport (4.2.0) lib/active_support/notifications/instrumenter.rb:19:in instrument' activesupport (4.2.0) lib/active_support/notifications.rb:164:ininstrument'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:30:in process_action' actionpack (4.2.0) lib/action_controller/metal/params_wrapper.rb:250:inprocess_action'
activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:18:in process_action' actionpack (4.2.0) lib/abstract_controller/base.rb:137:inprocess'
actionview (4.2.0) lib/action_view/rendering.rb:30:in process' actionpack (4.2.0) lib/action_controller/metal.rb:195:indispatch'
actionpack (4.2.0) lib/action_controller/metal/rack_delegation.rb:13:in dispatch' actionpack (4.2.0) lib/action_controller/metal.rb:236:inaction'
org/jruby/RubyProc.java:271:in call' actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:indispatch'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:42:in serve' actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:inserve'
org/jruby/RubyArray.java:1613:in each' actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:inserve'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in call' rack (1.6.0) lib/rack/etag.rb:24:incall'
rack (1.6.0) lib/rack/conditionalget.rb:25:in call' rack (1.6.0) lib/rack/head.rb:13:incall'
actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in call' actionpack (4.2.0) lib/action_dispatch/middleware/flash.rb:260:incall'
rack (1.6.0) lib/rack/session/abstract/id.rb:225:in context' rack (1.6.0) lib/rack/session/abstract/id.rb:220:incall'
actionpack (4.2.0) lib/action_dispatch/middleware/cookies.rb:560:in call' activerecord (4.2.0) lib/active_record/query_cache.rb:36:incall'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in call' activerecord (4.2.0) lib/active_record/migration.rb:378:incall'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in call' org/jruby/RubyProc.java:271:incall'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in _run_callbacks' activesupport (4.2.0) lib/active_support/callbacks.rb:738:in_run_call_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:incall'
actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in call' actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:incall'
actionpack (4.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in call' actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:incall'
railties (4.2.0) lib/rails/rack/logger.rb:38:in call_app' railties (4.2.0) lib/rails/rack/logger.rb:20:incall'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in tagged' activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:intagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in tagged' railties (4.2.0) lib/rails/rack/logger.rb:20:incall'
actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in call' rack (1.6.0) lib/rack/methodoverride.rb:22:incall'
rack (1.6.0) lib/rack/runtime.rb:18:in call' activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:incall'
rack (1.6.0) lib/rack/lock.rb:17:in call' actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:incall'
rack (1.6.0) lib/rack/sendfile.rb:113:in call' railties (4.2.0) lib/rails/engine.rb:518:incall'
railties (4.2.0) lib/rails/application.rb:164:in call' rack (1.6.0) lib/rack/content_length.rb:15:incall'
puma-2.10.2 (java) lib/puma/server.rb:492:in handle_request' puma-2.10.2 (java) lib/puma/server.rb:490:inhandle_request'
puma-2.10.2 (java) lib/puma/server.rb:363:in process_client' puma-2.10.2 (java) lib/puma/server.rb:359:inprocess_client'
puma-2.10.2 (java) lib/puma/server.rb:254:in run' org/jruby/RubyProc.java:271:incall'
puma-2.10.2 (java) lib/puma/thread_pool.rb:101:in `spawn_thread'

Rendered C:/jrails4_update/jruby/lib/ruby/gems/shared/gems/actionpack-4.2.0/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.0ms)
Rendered C:/jrails4_update/jruby/lib/ruby/gems/shared/gems/actionpack-4.2.0/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (0.0ms)
Rendered C:/jrails4_update/jruby/lib/ruby/gems/shared/gems/actionpack-4.2.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (0.0ms)
Rendered C:/jrails4_update/jruby/lib/ruby/gems/shared/gems/actionpack-4.2.0/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb within rescues/layout (47.0ms)
...

@TheSynthMaster
Copy link

P.S. it's enough to add the line

<%= Incident.first.created_at.to_s %>

to raise the error... I have the db configured in utc... using oracle enhanced adapter 1.5.0 branch rails42 and ojdbc6.jar to access the db...

config lines:

config.active_record.default_timezone = :utc
config.time_zone = "Rome"

mmasaki pushed a commit to mmasaki/ruby that referenced this issue May 30, 2015
  jruby/jruby#2310.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants