Skip to content

Instantly share code, notes, and snippets.

@oojikoo-gist
Created January 10, 2016 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oojikoo-gist/2788ba25e08625504e0a to your computer and use it in GitHub Desktop.
Save oojikoo-gist/2788ba25e08625504e0a to your computer and use it in GitHub Desktop.
rails: local_time patch
currently created a helper method to extract the core date from the string returned by the gem's local_date method
in views/
<%= extract_date(local_date(workflow.created_at, CommonConstants::DATE_FORMAT_LONG)) %>
# Parse the string generated by local_time gem
# Expectation :
# "<time data-format=\"%B %e, %Y\" data-local=\"time\" datetime=\"2015-10-28T11:19:54Z\">October 28, 2015</time>"
def extract_date(date_string)
date_string.split('>').pop.split('</')[0] rescue ''
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment