8.4. Times and dates
Ruby gives you lots of ways to manipulate times and dates. In fact, the extent and variety of the classes that represent times and/or dates, and the class and instance methods available through those classes, can be bewildering. So can the different ways in which instances of the various classes represent themselves. Want to know what the day we call April 24, 1705, would have been called in England prior to the calendar reform of 1752? Load the date package, and then ask
>> require 'date' => true >> Date.parse("April 24 1705").england.strftime("%B %d %Y") => "April 13 1705"
On the less exotic side, you can perform a number of useful and convenient manipulations on time and date objects.
Times and dates are manipulated through ...
Get The Well-Grounded Rubyist, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.