Project

General

Profile

Actions

Bug #17025

closed

`Time#ceil` does not work like `Rational#ceil` or `Float#ceil`

Added by tgxworld (Guo Xiang Tan) over 4 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
[ruby-core:99143]

Description

Current behavior

irb(main):011:0> time = Time.utc(2016, 4, 23, 0, 0, "0.123456789".to_r)
irb(main):012:0> time.ceil(9)
=> 2016-04-23 00:00:00.12345679 UTC
irb(main):013:0> time.ceil(10)
=> 2016-04-23 00:00:00 1234567891/10000000000 UTC
irb(main):014:0> time.ceil(11)
=> 2016-04-23 00:00:00 12345678901/100000000000 UTC

irb(main):015:0> "0.123456789".to_r.ceil(9)
=> (123456789/1000000000)

irb(main):016:0> "0.123456789".to_f.ceil(9)
=> 0.123456789

Expected Behavior

irb(main):011:0> time = Time.utc(2016, 4, 23, 0, 0, "0.123456789".to_r)
irb(main):012:0> time.ceil(9)
=> 2016-04-23 00:00:00.123456789 UTC
irb(main):012:0> time.ceil(10)
=> 2016-04-23 00:00:00.123456789 UTC
irb(main):012:0> time.ceil(11)
=> 2016-04-23 00:00:00.123456789 UTC

Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #16470: Issue with nanoseconds in Time#inspectClosedmatz (Yukihiro Matsumoto)Actions
Actions #1

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

  • Related to Feature #16470: Issue with nanoseconds in Time#inspect added
Actions #3

Updated by jeremyevans (Jeremy Evans) over 4 years ago

  • Status changed from Open to Closed

Applied in changeset git|520a734ad9c7348f4e4858ee24640f42c88fd389.


Fix Time#ceil when result should be the same as the receiver

Fixes [Bug #17025]

Updated by tgxworld (Guo Xiang Tan) over 4 years ago

Thank you for fixing this Jeremy.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0