-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Add Time#deconstruct_keys #6594
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
Conversation
9411a2e to
1e0efae
Compare
1e0efae to
7b3e9af
Compare
|
@jeremyevans You were completely right, macros were overthinking, removed them, and changed IDs to symbols for new keys, it looks cleaner this way. I still need advice on updating dependencies, |
7b3e9af to
a7d4e7b
Compare
a7d4e7b to
ee474ea
Compare
|
@jeremyevans Yeah, sorry, you are completely right. Trying to "quickly wrap it up" after exhausting week was not a good call of mine 🤷 |
jeremyevans
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for working on this!
ee474ea to
84b6893
Compare
|
I updated NEWS and fixed the typo, should I wait for @nobu's review, or can it be merged already? 🐱 |
|
Should be fine to merge after CI completes. |
I believe that
Timebeing suitable for pattern-matching is a reasonable feature with many possible usages, which will increase usability ofTimeand would be a good show case for pattern matching.Implementation decisions
UPD: As per Matz's decision, only
#deconstruct_keysis implemented now.Time#deconstruct_keys:[:year, :month, :day, :yday, :wday, :hour, :min, :sec, :subsec, :dst, :zone]monas a synonym formonth?.. But might be confusing if somebody will unpack the**restday, notmday, seems most reasonablePossible usages:
Time#to_h: added on a "why not" basis :) As we already have "convert to hash" in the form ofdeconstruct_keys(nil), having a canonic form seems harmless. Open for discussion.Time#deconstruct: returns time components in order[year, month, mday, hour, min, sec, subsec]