Add Time#deconstruct_keys - #6594
Merged
Merged
Conversation
zverok
force-pushed
the
time-deconstruct
branch
from
October 22, 2022 13:56
9411a2e to
1e0efae
Compare
jeremyevans
reviewed
Nov 7, 2022
jeremyevans
requested changes
Nov 12, 2022
zverok
force-pushed
the
time-deconstruct
branch
from
November 13, 2022 17:22
1e0efae to
7b3e9af
Compare
Contributor
Author
|
@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, |
zverok
force-pushed
the
time-deconstruct
branch
from
November 13, 2022 17:29
7b3e9af to
a7d4e7b
Compare
jeremyevans
requested changes
Nov 13, 2022
zverok
force-pushed
the
time-deconstruct
branch
from
November 19, 2022 16:52
a7d4e7b to
ee474ea
Compare
Contributor
Author
|
@jeremyevans Yeah, sorry, you are completely right. Trying to "quickly wrap it up" after exhausting week was not a good call of mine 🤷 |
jeremyevans
approved these changes
Nov 19, 2022
jeremyevans
left a comment
Contributor
There was a problem hiding this comment.
Looks good, thanks for working on this!
sampatbadhe
reviewed
Nov 22, 2022
zverok
force-pushed
the
time-deconstruct
branch
from
November 22, 2022 19:12
ee474ea to
84b6893
Compare
Contributor
Author
|
I updated NEWS and fixed the typo, should I wait for @nobu's review, or can it be merged already? 🐱 |
Contributor
|
Should be fine to merge after CI completes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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]