Created
February 28, 2011 23:46
-
-
Save tfe/848294 to your computer and use it in GitHub Desktop.
Ruby function to remove leading zeros (useful with strftime, place in application helper in Rails)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ruby function to remove leading zeros. | |
# Just put an asterisk (*) in front of any possible leading zero you want to remove. | |
# http://www.nullislove.com/2007/05/16/time-for-strftime/ | |
def strip_zeros_from_date(marked_date_string) | |
marked_date_string.gsub('*0', '').gsub('*', '') unless marked_date_string.nil? | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment