Skip to content

[Feature #18033] Make Time.new parse time strings - #4825

Merged
nobu merged 7 commits into
ruby:masterfrom
nobu:Time.new-string
Dec 16, 2022
Merged

[Feature #18033] Make Time.new parse time strings#4825
nobu merged 7 commits into
ruby:masterfrom
nobu:Time.new-string

Conversation

@nobu

@nobu nobu commented Sep 12, 2021

Copy link
Copy Markdown
Member

Time.new now parses strings such as the result of Time#inspect and restricted ISO-8601 formats.

Benchmarks: Iteration per second (i/s)

compare-ruby built-ruby
Time.new(2021) 547.707k 489.078k
1.12x -
Time.new(2021, 8, 22) 556.320k 518.588k
1.07x -
Time.new(2021, 8, 22, in: "+09:00") 1.564M 1.451M
1.08x -
Time.iso8601(iso8601) 147.019k 144.475k
1.02x -
Time.parse(iso8601) 53.925k 53.384k
1.01x -
Time.parse(inspect) 53.078k 52.891k
1.00x -
Time.new(iso8601) rescue Time.iso8601(iso8601) 93.252k 1.433M
- 15.37x
Time.new(inspect) rescue Time.parse(inspect) 43.141k 1.443M
- 33.45x

@nobu
nobu force-pushed the Time.new-string branch 2 times, most recently from 314f8b3 to ffdc20b Compare September 20, 2021 08:33
@nobu
nobu force-pushed the Time.new-string branch 2 times, most recently from 9841fb9 to 875d6e3 Compare October 24, 2021 12:00
@nobu
nobu force-pushed the Time.new-string branch 2 times, most recently from 784abf6 to 38a0934 Compare December 4, 2021 07:43
@nobu
nobu requested a review from akr November 17, 2022 08:25
Comment thread test/ruby/test_time.rb Outdated
Comment thread time.c Outdated
Comment thread time.c Outdated
Comment thread time.c Outdated
Comment thread time.c Outdated
@nobu
nobu force-pushed the Time.new-string branch 2 times, most recently from 4a99539 to dda1058 Compare November 18, 2022 05:50
@nobu
nobu requested a review from akr November 18, 2022 06:45
Comment thread test/ruby/test_time.rb Outdated
@nobu
nobu force-pushed the Time.new-string branch 2 times, most recently from f77febf to c4e66a6 Compare November 20, 2022 07:14
@nobu
nobu requested a review from akr November 20, 2022 09:56
Comment thread time.c Outdated
Comment thread time.c Outdated
Comment thread time.c Outdated
nobu added 7 commits December 16, 2022 20:43
`Time.new` now parses strings such as the result of `Time#inspect`
and restricted ISO-8601 formats.
Which limits the precision of subsecond. Defaulted to 9, that
means nanosecond.
* 4-digits or more is required as year
* Minutes and seconds parts are not ommittable
@nobu
nobu merged commit 3d2eb7c into ruby:master Dec 16, 2022
@nobu
nobu deleted the Time.new-string branch December 16, 2022 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants