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

[Data] Normalize all dates in releases.yml to Date instead of String #3375

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

epistrephein
Copy link
Contributor

@epistrephein epistrephein commented Sep 24, 2024

In _data/releases.yml, 4 of the total 208 dates under the date: key are represented with quotes instead of without.

This has the side effect that when the file is YAML-parsed, these dates are parsed as Strings instead of Dates, creating an unwanted inconsistency of classes.

This PR normalizes the 4 dates removing the quotes so that they're all parsed as Date class.

require 'yaml'
yaml = YAML.unsafe_load_file('_data/releases.yml')

# master
yaml.filter_map { |i| i['version'] unless i['date'].is_a?(Date) }
# => ["3.2.5", "3.1.6", "3.1.5", "3.0.7"]
yaml.find { |i| i['version'] == '3.2.5' }['date']
# => "2024-07-26"


# this branch
yaml.filter_map { |i| i['version'] unless i['date'].is_a?(Date) }
# => []
yaml.find { |i| i['version'] == '3.2.5' }['date']
# => #<Date: 2024-07-26 ((2460518j,0s,0n),+0s,-Infj)>

(see #3146 for a similar fix some time ago)

@epistrephein epistrephein requested a review from a team as a code owner September 24, 2024 10:00
Copy link
Member

@JuanitoFatas JuanitoFatas left a comment

Choose a reason for hiding this comment

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

Love the consistency, thanks!

@JuanitoFatas JuanitoFatas merged commit e86e532 into ruby:master Oct 1, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants