* [ruby-core:92306] [Ruby trunk Feature#15772] Proposal: Add Time#ceil
[not found] <redmine.issue-15772.20190416150356@ruby-lang.org>
@ 2019-04-16 15:03 ` manga.osyo
2019-05-22 5:30 ` [ruby-core:92759] " matz
` (2 subsequent siblings)
3 siblings, 0 replies; 4+ messages in thread
From: manga.osyo @ 2019-04-16 15:03 UTC (permalink / raw)
To: ruby-core
Issue #15772 has been reported by osyo (manga osyo).
----------------------------------------
Feature #15772: Proposal: Add Time#ceil
https://bugs.ruby-lang.org/issues/15772
* Author: osyo (manga osyo)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
## Summary
proposal for a method that rounds up the decimal part of `Time` (nanosecond) to the specified digit.
## Current status
* `Time#round` and `Time#floor` (https://bugs.ruby-lang.org/issues/15653) are defined.
* However, `Time#ceil` is not defined.
* So, I would like to respond flexibly when I would like to control decimal precision.
## Propose `Time#ceil`
Below is example code.
```ruby
require 'time'
t = Time.utc(2010,3,30, 5,43,"25.0123456789".to_r)
p t.iso8601(10) #=> "2010-03-30T05:43:25.0123456789Z"
p t.ceil(0).iso8601(10) #=> "2010-03-30T05:43:26.0000000000Z"
p t.ceil(1).iso8601(10) #=> "2010-03-30T05:43:25.1000000000Z"
p t.ceil(2).iso8601(10) #=> "2010-03-30T05:43:25.0200000000Z"
p t.ceil(3).iso8601(10) #=> "2010-03-30T05:43:25.0130000000Z"
p t.ceil(4).iso8601(10) #=> "2010-03-30T05:43:25.0124000000Z"
p t.ceil(5).iso8601(10) #=> "2010-03-30T05:43:25.0123500000Z"
p t.ceil(6).iso8601(10) #=> "2010-03-30T05:43:25.0123460000Z"
p t.ceil(7).iso8601(10) #=> "2010-03-30T05:43:25.0123457000Z"
p t.ceil(8).iso8601(10) #=> "2010-03-30T05:43:25.0123456800Z"
p t.ceil(9).iso8601(10) #=> "2010-03-30T05:43:25.0123456790Z"
p t.ceil(10).iso8601(10) #=> "2010-03-30T05:43:25.0123456790Z"
# default argument is 0
p t.ceil.iso8601(10) #=> "2010-03-30T05:43:26.0000000000Z"
t = Time.utc(1999,12,31, 23,59,59)
p (t + 0.4).ceil.iso8601(3) #=> "2000-01-01T00:00:00.000Z"
p (t + 0.49).ceil.iso8601(3) #=> "2000-01-01T00:00:00.000Z"
p (t + 0.5).ceil.iso8601(3) #=> "2000-01-01T00:00:00.000Z"
p (t + 1.4).ceil.iso8601(3) #=> "2000-01-01T00:00:01.000Z"
p (t + 1.49).ceil.iso8601(3) #=> "2000-01-01T00:00:01.000Z"
p (t + 1.5).ceil.iso8601(3) #=> "2000-01-01T00:00:01.000Z"
t = Time.utc(1999,12,31, 23,59,59)
p (t + 0.123456789).ceil(4).iso8601(6) #=> "1999-12-31T23:59:59.123500Z"
```
pull request : https://github.com/ruby/ruby/pull/2133
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-core:92759] [Ruby trunk Feature#15772] Proposal: Add Time#ceil
[not found] <redmine.issue-15772.20190416150356@ruby-lang.org>
2019-04-16 15:03 ` [ruby-core:92306] [Ruby trunk Feature#15772] Proposal: Add Time#ceil manga.osyo
@ 2019-05-22 5:30 ` matz
2019-05-23 2:59 ` [ruby-core:92790] " manga.osyo
2019-05-23 13:41 ` [ruby-core:92799] " nobu
3 siblings, 0 replies; 4+ messages in thread
From: matz @ 2019-05-22 5:30 UTC (permalink / raw)
To: ruby-core
Issue #15772 has been updated by matz (Yukihiro Matsumoto).
Accepted.
Matz.
----------------------------------------
Feature #15772: Proposal: Add Time#ceil
https://bugs.ruby-lang.org/issues/15772#change-78124
* Author: osyo (manga osyo)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
## Summary
proposal for a method that rounds up the decimal part of `Time` (nanosecond) to the specified digit.
## Current status
* `Time#round` and `Time#floor` (https://bugs.ruby-lang.org/issues/15653) are defined.
* However, `Time#ceil` is not defined.
* So, I would like to respond flexibly when I would like to control decimal precision.
## Propose `Time#ceil`
Below is example code.
```ruby
require 'time'
t = Time.utc(2010,3,30, 5,43,"25.0123456789".to_r)
p t.iso8601(10) #=> "2010-03-30T05:43:25.0123456789Z"
p t.ceil(0).iso8601(10) #=> "2010-03-30T05:43:26.0000000000Z"
p t.ceil(1).iso8601(10) #=> "2010-03-30T05:43:25.1000000000Z"
p t.ceil(2).iso8601(10) #=> "2010-03-30T05:43:25.0200000000Z"
p t.ceil(3).iso8601(10) #=> "2010-03-30T05:43:25.0130000000Z"
p t.ceil(4).iso8601(10) #=> "2010-03-30T05:43:25.0124000000Z"
p t.ceil(5).iso8601(10) #=> "2010-03-30T05:43:25.0123500000Z"
p t.ceil(6).iso8601(10) #=> "2010-03-30T05:43:25.0123460000Z"
p t.ceil(7).iso8601(10) #=> "2010-03-30T05:43:25.0123457000Z"
p t.ceil(8).iso8601(10) #=> "2010-03-30T05:43:25.0123456800Z"
p t.ceil(9).iso8601(10) #=> "2010-03-30T05:43:25.0123456790Z"
p t.ceil(10).iso8601(10) #=> "2010-03-30T05:43:25.0123456790Z"
# default argument is 0
p t.ceil.iso8601(10) #=> "2010-03-30T05:43:26.0000000000Z"
t = Time.utc(1999,12,31, 23,59,59)
p (t + 0.4).ceil.iso8601(3) #=> "2000-01-01T00:00:00.000Z"
p (t + 0.49).ceil.iso8601(3) #=> "2000-01-01T00:00:00.000Z"
p (t + 0.5).ceil.iso8601(3) #=> "2000-01-01T00:00:00.000Z"
p (t + 1.4).ceil.iso8601(3) #=> "2000-01-01T00:00:01.000Z"
p (t + 1.49).ceil.iso8601(3) #=> "2000-01-01T00:00:01.000Z"
p (t + 1.5).ceil.iso8601(3) #=> "2000-01-01T00:00:01.000Z"
t = Time.utc(1999,12,31, 23,59,59)
p (t + 0.123456789).ceil(4).iso8601(6) #=> "1999-12-31T23:59:59.123500Z"
```
pull request : https://github.com/ruby/ruby/pull/2133
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-core:92790] [Ruby trunk Feature#15772] Proposal: Add Time#ceil
[not found] <redmine.issue-15772.20190416150356@ruby-lang.org>
2019-04-16 15:03 ` [ruby-core:92306] [Ruby trunk Feature#15772] Proposal: Add Time#ceil manga.osyo
2019-05-22 5:30 ` [ruby-core:92759] " matz
@ 2019-05-23 2:59 ` manga.osyo
2019-05-23 13:41 ` [ruby-core:92799] " nobu
3 siblings, 0 replies; 4+ messages in thread
From: manga.osyo @ 2019-05-23 2:59 UTC (permalink / raw)
To: ruby-core
Issue #15772 has been updated by osyo (manga osyo).
Thank you!
----------------------------------------
Feature #15772: Proposal: Add Time#ceil
https://bugs.ruby-lang.org/issues/15772#change-78160
* Author: osyo (manga osyo)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
## Summary
proposal for a method that rounds up the decimal part of `Time` (nanosecond) to the specified digit.
## Current status
* `Time#round` and `Time#floor` (https://bugs.ruby-lang.org/issues/15653) are defined.
* However, `Time#ceil` is not defined.
* So, I would like to respond flexibly when I would like to control decimal precision.
## Propose `Time#ceil`
Below is example code.
```ruby
require 'time'
t = Time.utc(2010,3,30, 5,43,"25.0123456789".to_r)
p t.iso8601(10) #=> "2010-03-30T05:43:25.0123456789Z"
p t.ceil(0).iso8601(10) #=> "2010-03-30T05:43:26.0000000000Z"
p t.ceil(1).iso8601(10) #=> "2010-03-30T05:43:25.1000000000Z"
p t.ceil(2).iso8601(10) #=> "2010-03-30T05:43:25.0200000000Z"
p t.ceil(3).iso8601(10) #=> "2010-03-30T05:43:25.0130000000Z"
p t.ceil(4).iso8601(10) #=> "2010-03-30T05:43:25.0124000000Z"
p t.ceil(5).iso8601(10) #=> "2010-03-30T05:43:25.0123500000Z"
p t.ceil(6).iso8601(10) #=> "2010-03-30T05:43:25.0123460000Z"
p t.ceil(7).iso8601(10) #=> "2010-03-30T05:43:25.0123457000Z"
p t.ceil(8).iso8601(10) #=> "2010-03-30T05:43:25.0123456800Z"
p t.ceil(9).iso8601(10) #=> "2010-03-30T05:43:25.0123456790Z"
p t.ceil(10).iso8601(10) #=> "2010-03-30T05:43:25.0123456790Z"
# default argument is 0
p t.ceil.iso8601(10) #=> "2010-03-30T05:43:26.0000000000Z"
t = Time.utc(1999,12,31, 23,59,59)
p (t + 0.4).ceil.iso8601(3) #=> "2000-01-01T00:00:00.000Z"
p (t + 0.49).ceil.iso8601(3) #=> "2000-01-01T00:00:00.000Z"
p (t + 0.5).ceil.iso8601(3) #=> "2000-01-01T00:00:00.000Z"
p (t + 1.4).ceil.iso8601(3) #=> "2000-01-01T00:00:01.000Z"
p (t + 1.49).ceil.iso8601(3) #=> "2000-01-01T00:00:01.000Z"
p (t + 1.5).ceil.iso8601(3) #=> "2000-01-01T00:00:01.000Z"
t = Time.utc(1999,12,31, 23,59,59)
p (t + 0.123456789).ceil(4).iso8601(6) #=> "1999-12-31T23:59:59.123500Z"
```
pull request : https://github.com/ruby/ruby/pull/2133
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-core:92799] [Ruby trunk Feature#15772] Proposal: Add Time#ceil
[not found] <redmine.issue-15772.20190416150356@ruby-lang.org>
` (2 preceding siblings ...)
2019-05-23 2:59 ` [ruby-core:92790] " manga.osyo
@ 2019-05-23 13:41 ` nobu
3 siblings, 0 replies; 4+ messages in thread
From: nobu @ 2019-05-23 13:41 UTC (permalink / raw)
To: ruby-core
Issue #15772 has been updated by nobu (Nobuyoshi Nakada).
Status changed from Open to Closed
Closed by f5415a95ce1d393a3fd1d7f657ba85d85171356a
I missed the tag to close the ticket.
----------------------------------------
Feature #15772: Proposal: Add Time#ceil
https://bugs.ruby-lang.org/issues/15772#change-78173
* Author: osyo (manga osyo)
* Status: Closed
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
## Summary
proposal for a method that rounds up the decimal part of `Time` (nanosecond) to the specified digit.
## Current status
* `Time#round` and `Time#floor` (https://bugs.ruby-lang.org/issues/15653) are defined.
* However, `Time#ceil` is not defined.
* So, I would like to respond flexibly when I would like to control decimal precision.
## Propose `Time#ceil`
Below is example code.
```ruby
require 'time'
t = Time.utc(2010,3,30, 5,43,"25.0123456789".to_r)
p t.iso8601(10) #=> "2010-03-30T05:43:25.0123456789Z"
p t.ceil(0).iso8601(10) #=> "2010-03-30T05:43:26.0000000000Z"
p t.ceil(1).iso8601(10) #=> "2010-03-30T05:43:25.1000000000Z"
p t.ceil(2).iso8601(10) #=> "2010-03-30T05:43:25.0200000000Z"
p t.ceil(3).iso8601(10) #=> "2010-03-30T05:43:25.0130000000Z"
p t.ceil(4).iso8601(10) #=> "2010-03-30T05:43:25.0124000000Z"
p t.ceil(5).iso8601(10) #=> "2010-03-30T05:43:25.0123500000Z"
p t.ceil(6).iso8601(10) #=> "2010-03-30T05:43:25.0123460000Z"
p t.ceil(7).iso8601(10) #=> "2010-03-30T05:43:25.0123457000Z"
p t.ceil(8).iso8601(10) #=> "2010-03-30T05:43:25.0123456800Z"
p t.ceil(9).iso8601(10) #=> "2010-03-30T05:43:25.0123456790Z"
p t.ceil(10).iso8601(10) #=> "2010-03-30T05:43:25.0123456790Z"
# default argument is 0
p t.ceil.iso8601(10) #=> "2010-03-30T05:43:26.0000000000Z"
t = Time.utc(1999,12,31, 23,59,59)
p (t + 0.4).ceil.iso8601(3) #=> "2000-01-01T00:00:00.000Z"
p (t + 0.49).ceil.iso8601(3) #=> "2000-01-01T00:00:00.000Z"
p (t + 0.5).ceil.iso8601(3) #=> "2000-01-01T00:00:00.000Z"
p (t + 1.4).ceil.iso8601(3) #=> "2000-01-01T00:00:01.000Z"
p (t + 1.49).ceil.iso8601(3) #=> "2000-01-01T00:00:01.000Z"
p (t + 1.5).ceil.iso8601(3) #=> "2000-01-01T00:00:01.000Z"
t = Time.utc(1999,12,31, 23,59,59)
p (t + 0.123456789).ceil(4).iso8601(6) #=> "1999-12-31T23:59:59.123500Z"
```
pull request : https://github.com/ruby/ruby/pull/2133
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-05-23 13:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <redmine.issue-15772.20190416150356@ruby-lang.org>
2019-04-16 15:03 ` [ruby-core:92306] [Ruby trunk Feature#15772] Proposal: Add Time#ceil manga.osyo
2019-05-22 5:30 ` [ruby-core:92759] " matz
2019-05-23 2:59 ` [ruby-core:92790] " manga.osyo
2019-05-23 13:41 ` [ruby-core:92799] " nobu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).