title: Working with and testing dates in rails
body: <p>My application uses dates a lot.  A lot of ajax calls and urls involve datetimes and I find the typical format '1920-10-10 18:30:00' to be unfriendly for these purposes.  I work around this by creating a helper method that basically strips the unnecessary characters out of the date (192010101830) and another method for converting the string back in to a date object.</p>
  
  <p>When I build a url it goes something like this:</p>
  
  <pre><code>=link_to "Send Date", thing_my_date_path(date_to_string(DateTime.now))
  </code></pre>
  
  <p>Then when the thing_date action receives, it converts the parameter back in to a datetime object</p>
  
  <pre><code>def my_date
    @date = string_to_date(params[:mydate])
    ....
  end
  </code></pre>
  
  <p>This works fine in development.  However I am completely open to other suggestions.</p>
  
  <p>The problem is when I go to test my application.  Tests fail because the helper methods for date_to_string and string_to_date are not present.  I could include them in the tests but I feel like they should be kept separate.</p>
  
  <p>So I'm looking for<br>
  a) a better way to pass dates around, and more importantly</p>
  
  <p>b) a method of testing an action that is dependent on helper methods.</p>