Ruby 2.7 has added new methods for Time:

#### Time#floor

There are cases where we want to truncate decimals in order to compare or save times with different accuracy. Ruby adds Time#floor to truncate the specified decimal places i.e. rounding down the decimal part of Time to the specified digit.

In mathematics and computer science, the floor function is the function that takes as input a real number x and gives as output the greatest integer less than or equal to x

Ruby 2.7 now allows to perform this floor operation with specification of precision:

The default precision value that is passed to the function is 0:

#### Time#ceil

Since Time#floor was introduced, the complementary Time#ceil was also added to control decimal precision and rounding up the decimal part of Time to the specified digit.

The default precision value that is passed to the function is 0:

Time#floor and Time#ceil act as good ways to compare time in smaller scale and desired precision in applications that would care about and rely on times in microseconds, etc and below.