Skip to content

Instantly share code, notes, and snippets.

@achilles42
Last active October 6, 2015 04:08
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 achilles42/7fb04e506a765ad3d721 to your computer and use it in GitHub Desktop.
Save achilles42/7fb04e506a765ad3d721 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Function to print strftime results
def print_strftime_formats(a, current_date)
a.each do |format|
b = "%#{format}"
output = current_date.strftime(b)
puts "t.strftime('#{b}'), => #{output}"
end
end
a = ('a'..'z').to_a
A = ('A'..'Z').to_a
current_date = Time.now
# calling and printing strftime results on current date
puts "DateTime: #{current_date}\n"
puts "\n\nFor a to z"
print_strftime_formats(a, current_date)
puts "\n\nFor A to Z"
print_strftime_formats(A, current_date)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment