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

Time.new and Time#getlocal don't accept a timezone object or a UTC offset string #1717

Open
deepj opened this issue Jul 7, 2019 · 5 comments · May be fixed by #3740
Open

Time.new and Time#getlocal don't accept a timezone object or a UTC offset string #1717

deepj opened this issue Jul 7, 2019 · 5 comments · May be fixed by #3740

Comments

@deepj
Copy link

deepj commented Jul 7, 2019

This a new thing in Ruby 2.6. I personally use this in one script loading some Timezones from various coordinates.

To reproduce:

ruby -e 'require "tzinfo"; puts Time.new(2019, 5, 8, 2, 34, 23, TZInfo::Timezone.get("Europe/Zurich"))'

MR 2.6.3:

2019-05-08 02:34:23 +0200

TruffleRuby 19.1.0

-e:1:in `coerce_to_failed': Coercion error: #<TZInfo::DataTimezone: Europe/Zurich>.to_int => Integer failed (TypeError)
	from -e:1:in `execute_coerce_to'
	from -e:1:in `coerce_to'
	from -e:1:in `coerce_to_exact_num'
	from -e:1:in `coerce_to_utc_offset'
	from -e:1:in `new'
	from -e:1:in `<main>'
@deepj deepj closed this as completed Jun 8, 2020
@eregon eregon reopened this Jun 19, 2020
@deepj
Copy link
Author

deepj commented Jun 24, 2022

Now the error is a bit different:

<internal:core> core/type.rb:104:in `coerce_to_failed': wrong argument type TZInfo::DataTimezone (expected Integer) (TypeError)
	from <internal:core> core/type.rb:93:in `execute_coerce_to'
	from <internal:core> core/type.rb:85:in `coerce_to'
	from <internal:core> core/type.rb:457:in `coerce_to_exact_num'
	from <internal:core> core/type.rb:472:in `coerce_to_utc_offset'
	from <internal:core> core/time.rb:459:in `new'
	from -e:1:in `<main>'
<internal:core> core/type.rb:91:in `execute_coerce_to': undefined method `to_int' for #<TZInfo::DataTimezone: Europe/Zurich> (NoMethodError)
Did you mean?  taint
	from <internal:core> core/type.rb:85:in `coerce_to'
	from <internal:core> core/type.rb:457:in `coerce_to_exact_num'
	from <internal:core> core/type.rb:472:in `coerce_to_utc_offset'
	from <internal:core> core/time.rb:459:in `new'
	from -e:1:in `<main>'

No issue with MRI rubies thought

@andrykonchin andrykonchin self-assigned this Aug 30, 2022
@andrykonchin
Copy link
Member

Thank you for reporting!

It can be reproduced easily. Will work on a fix.

@rwstauner
Copy link
Collaborator

I traced this back to
Feature 14850
with this commit
ruby/ruby@ee58c63

The 3.3 docs have more info on how it works:
https://docs.ruby-lang.org/en/3.3/Time.html#class-Time-label-Timezone+Objects

@rwstauner
Copy link
Collaborator

@andrykonchin Did you do any work towards this? Do you mind if I work on a PR for it?

@andrykonchin
Copy link
Member

andrykonchin commented Feb 8, 2024

No, timezone object isn't supported yet. It will be great to have it implemented!

It should be already covered with specs AFAIK (for #getlocal and .new methods)

@rwstauner rwstauner self-assigned this Feb 8, 2024
rwstauner added a commit to rwstauner/truffleruby that referenced this issue Dec 13, 2024
rwstauner added a commit to rwstauner/truffleruby that referenced this issue Dec 13, 2024
…localtime}

closes oracle#1717

For compatibility with https://bugs.ruby-lang.org/issues/14850

Co-authored-by: Manef Zahra <[email protected]>
Co-authored-by: Patrick Lin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment