# Active Support and Time

DevFeed: [Active Support and Time](<https://devfeed.tech/articles/active-support-and-time-21039.md>)

Original publisher: [Read original article](<https://jakeyesbeck.com/2015/08/30/active-support-and-time/>)

Published: 2015-08-30T12:00:00Z

Content type: article

Language: en

Sources: [Jake Yesbeck](<https://devfeed.tech/sources/jake-yesbeck.md>)

Topics: [Ruby](<https://devfeed.tech/topics/ruby.md>), [Library](<https://devfeed.tech/topics/library.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Software](<https://devfeed.tech/topics/software.md>)

Tags: [article](<https://devfeed.tech/tags/article.md>), [developer](<https://devfeed.tech/tags/developer.md>), [libraries](<https://devfeed.tech/tags/libraries.md>), [library](<https://devfeed.tech/tags/library.md>), [programming](<https://devfeed.tech/tags/programming.md>), [ruby](<https://devfeed.tech/tags/ruby.md>), [timezone](<https://devfeed.tech/tags/timezone.md>)

## AI overview

This article examines inconsistencies in Ruby's Active Support library when handling time. It covers convenient date and time calculations, timezone offsets, conversion to Epoch seconds with Ruby's Time#to_i, and the misleading assumption that every month has 30 days.

## Source excerpt

If a list was compiled of useful Ruby libraries, Active Support would be close to the top. Based on the documentation alone, it is apparent that a very large amount of time went into thinking about the roles Active Support should play and the functionality it should support. From string manipulation to internationalization, Active Support seems to simply do it all. However, even a profoundly useful library like Active Support still has a few inconsistencies with everyone's favorite subject: Time Calculation. Time wounds all heals Personally, the thing that keeps me up at night, the monster in my closet, the beast waiting to grab my foot when I accidentally let it hang over the bed while sleeping, is time calculation in programming. Regardless of the task, however simple it may seem, calculating time offsets or time zone correction continues to be a tremendous pain point. Now, to demonstrate just how crazy things can be, let's pick on Active Support. Active Support grants a myriad of methods for even the most impatient Software Artisan. For example, if one were to ask for this instant in time, a day ago, Active Support makes it possible. 1.day.ago # => 2015-08-29 18:44:55 -0700 Likewise, basic date addition and subtraction is just as easy. three_days_from_now = Time.now + 3.days #=> 2015-09-01 18:46:34 -0700 three_days_from_now + 12.hours # => 2015-09-03 06:48:28 -0700 Great! Very simple, seemingly arbitrary time calculation has never been easier. So what could be the catch? Obviously there isn't one, if there were then this article would have to continue and I'm sure everyone has had quite enough. to_i is not always easy Had enough? Too bad. The topic of to_i still has to be discussed with relation to the Time class. Ruby's Time class exposes a method to_i which can be used to convert a Time to an Integer. This Integeris the sum of seconds passed since Epoch. Using Epoch time can be useful for some systems that want to avoid doing timezone conversion. In fact, it mi