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

DateTime#civil doesn't accept milliseconds #1951

Closed
blaet opened this issue Sep 5, 2014 · 2 comments
Closed

DateTime#civil doesn't accept milliseconds #1951

blaet opened this issue Sep 5, 2014 · 2 comments

Comments

@blaet
Copy link

blaet commented Sep 5, 2014

MRI 1.9.3 apparently allows passing milliseconds into DateTime#civil, contrary to docs, which state that that argument should be the timezone offset. In cases where this feature is used (e.g. aws/aws-sdk-ruby) JRuby returns an error, see below:

jruby-1.7.13 :004 > DateTime.civil(2014, 01, 01, 12, 31, 14, 139)
ArgumentError: Invalid offset: 139
    from /Users/bram.devries/.rvm/rubies/jruby-1.7.13/lib/ruby/1.9/date.rb:710:in `chronology'
    from /Users/bram.devries/.rvm/rubies/jruby-1.7.13/lib/ruby/1.9/date.rb:1706:in `civil'
    from (irb):4:in `evaluate'
    from org/jruby/RubyKernel.java:1101:in `eval'
    from org/jruby/RubyKernel.java:1501:in `loop'
    from org/jruby/RubyKernel.java:1264:in `catch'
    from org/jruby/RubyKernel.java:1264:in `catch'

Opposed to 1.9.3, which ignores the argument altogether.

1.9.3-p547 :003 > DateTime.civil(2014, 01, 01, 12, 31, 14, 139)
 => #<DateTime: 2014-01-01T12:31:14+00:00 ((2456659j,45074s,0n),+0s,2299161j)>
@blaet blaet changed the title DateTime#civil doesn't allow miliseconds DateTime#civil doesn't allow milliseconds Sep 5, 2014
@blaet blaet changed the title DateTime#civil doesn't allow milliseconds DateTime#civil doesn't accept milliseconds Sep 5, 2014
@rtyler
Copy link

rtyler commented Aug 7, 2015

This appears to still be present

@kares
Copy link
Member

kares commented Mar 1, 2018

jruby-1.7.13 :004 > DateTime.civil(2014, 01, 01, 12, 31, 14, 139)
ArgumentError: Invalid offset: 139

for the record the 6-th argument on DateTime.civil is offset (and has always been - even in 1.9.3)
while MRI allows arbitrary offsets JRuby only accepts valid ones e.g. 1.to_r / 24 or '-07:00'
... I am into doing a rewrite on date.rb but will stil rely on JODA for internals so the 'incompat' stays

do not think this matters much as users (me included) usually are confused about that argument.
its probably for the best to fail early -> in MRI that 139 value certainly did not set any milliseconds

@kares kares closed this as completed Mar 1, 2018
@kares kares added this to the Invalid or Duplicate milestone Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants