From: "werelnon (Malcolm Patterson) via ruby-core" Date: 2024-03-14T00:26:24+00:00 Subject: [ruby-core:117132] [Ruby master Bug#20334] Time.to_i truncates a fractional timestamp instead of rounding up Issue #20334 has been reported by werelnon (Malcolm Patterson). ---------------------------------------- Bug #20334: Time.to_i truncates a fractional timestamp instead of rounding up https://bugs.ruby-lang.org/issues/20334 * Author: werelnon (Malcolm Patterson) * Status: Open * ruby -v: 3.2.2 * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- Simple steps that can be executed in a ruby interactive shell ``` irb(main):007> t = Time.now => 2024-03-14 00:23:55.983885525 +0000 irb(main):008> t.to_f => 1710375835.9838855 irb(main):009> t.to_i => 1710375835 ``` Based on the example the result of `t.to_f.round` is the better result? -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/