Project

General

Profile

Actions

Feature #22530

open

Deprecate fractional day support for Date

Feature #22530: Deprecate fractional day support for Date
1

Added by jeremyevans0 (Jeremy Evans) about 10 hours ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:127400]

Description

I think we should deprecate fractional day support in Date. This has been discussed in #21264 as well as in the PR to convert from the current C implementation to a Ruby implementation (https://github.com/ruby/date/pull/155#pullrequestreview-5639933517). At least @Eregon (Benoit Daloze) and @rhenium (Kazuki Yamaguchi) have also indicated support for dropping it.

@matz (Yukihiro Matsumoto) commented on the PR (https://github.com/ruby/date/pull/155#issuecomment-6757669093) stating that we should have a separate ticket for this, which is why I'm opening this ticket.

Here's how fractional day support currently works:

d1 = Date.new(2000, 1, 2)
# => #<Date: 2000-01-02 ((2451546j,0s,0n),+0s,2299161j)>
d2 = Date.new(2000, 1, 2.5r)
# => #<Date: 2000-01-02 ((2451546j,0s,0n),+0s,2299161j)>

d1 = d2
# => true

d3 = d1 + 0.5r
# => #<Date: 2000-01-02 ((2451546j,43200s,0n),+0s,2299161j)>
d3 == d1
# => false
d4 = d3 + 0.5r
# => #<Date: 2000-01-03 ((2451547j,0s,0n),+0s,2299161j)>

Basically, fractional days are ignored in the constructors, but are respected by + and -. This behavior doesn't really make sense. I assume the only reason this choice was made historically was the Date and DateTime implementations were shared, and it was easier to have the same behavior for both, even though the behavior for Date makes no sense.

In terms of deprecating fractional days, I propose we deprecate this in the C implementation released in Ruby 4.1. Hopefully by Ruby 4.2, the Ruby implementation of date will fix the remaining issues and we can merge it. This approach avoids complicating the Ruby implementation of Date. I've submitted a PR to date for the deprecation: https://github.com/ruby/date/pull/201

No data to display

Actions

Also available in: PDF Atom