Can't load time with year greater than or equal to 10000
Open
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 597
- Forks
- 223
- Avg merge
- 11h 23m
- Merged PRs (30d)
- 3
Description
Steps to reproduce
require "psych"
require "time"
require "minitest/autorun"
class YearTenThousandTest < Minitest::Test
def test_year_ten_thousand
time = Time.parse("10000-01-01 00:00:00")
yaml_string = Psych.dump(time)
yaml_time = Psych.load(yaml_string)
assert_equal yaml_time, time
end
end
Expected behavior
Expected Psych.load to return a Time object, like it does for years <= 9999.
Actual behavior
It returns a string.
System configuration
Ruby version: 2.6.1
Originally reported as https://github.com/rails/rails/issues/35783
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the YearTenThousandTest example, focusing on Psych.dump and Psych.load with a Time parsed by Time.parse. Trace how Psych decides whether a dumped time is loaded as a Time or String, then add coverage for year >= 10000 and verify the round trip returns a Time object.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby, yaml
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100