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

Enable parsing of Time Args with 10 parameters #2411

Merged
merged 5 commits into from
Feb 18, 2023
Merged

Enable parsing of Time Args with 10 parameters #2411

merged 5 commits into from
Feb 18, 2023

Conversation

b-n
Copy link
Member

@b-n b-n commented Feb 6, 2023

Quick follow on from #2410

Adds ten argument support (e.g. Time.local(*Time.now.to_a))
Refactor the existing logic to do all type and range checking within the initial parsing. (See the commit details for some more info).

This solves a bunch of problems I had in my head about how to structure this code. It might be somewhat reusable for the likes of Time::new, but will have to see.

Related to: #2223

TODO: It appears the Ten args variant and the 1..=8 variants both
support the same parsing of dynamic arguments (e.g. mon supporting
"feb"). This is just a stop gap to ten args support, however this code
is expected to change somewhat to avoid duplication.
@b-n b-n requested a review from lopopolo February 6, 2023 06:31
@b-n b-n changed the title B n/time ten args Enable parsing of Time Args with 10 parameters Feb 6, 2023
The previous structure relied on always casting to a i64, which is not
always the case (see parsing of month, and seconds). This comes at the
added cost of always parsing all arguments, however that ends up being a
reality in the likes of `Time::utc` etc.
@b-n b-n added A-ruby-core Area: Ruby Core types. C-enhancement Category: New feature or request. C-quality Category: Refactoring, cleanup, and quality improvements. B-mruby Backend: Implementation of artichoke-core using mruby. labels Feb 9, 2023
artichoke-backend/src/extn/core/time/args.rs Outdated Show resolved Hide resolved
artichoke-backend/src/extn/core/time/args.rs Outdated Show resolved Hide resolved
artichoke-backend/src/extn/core/time/args.rs Outdated Show resolved Hide resolved
artichoke-backend/src/extn/core/time/args.rs Outdated Show resolved Hide resolved
b-n and others added 2 commits February 17, 2023 12:32
Co-authored-by: Ryan Lopopolo <rjl@hyperbo.la>
`to_int` should gaurnatee a conversion is possible to an i64.

Co-authored-by: Ryan Lopopolo <rjl@hyperbo.la>
Copy link
Member

@lopopolo lopopolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lookgs good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ruby-core Area: Ruby Core types. B-mruby Backend: Implementation of artichoke-core using mruby. C-enhancement Category: New feature or request. C-quality Category: Refactoring, cleanup, and quality improvements.
Development

Successfully merging this pull request may close these issues.

None yet

2 participants