Skip to content

Instantly share code, notes, and snippets.

@itspriddle
Created June 23, 2010 02:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itspriddle/449406 to your computer and use it in GitHub Desktop.
Save itspriddle/449406 to your computer and use it in GitHub Desktop.
# Print the list of special characters used with strftime
def print_strftime_keys
now = Time.parse('2010-06-01')
('A'..'Z').to_a.each do |letter|
[letter, letter.downcase].each do |l|
time = now.strftime("%#{l}")
puts "'#{l}' => '#{time}'"
end
end
end
# 'A' => 'Tuesday'
# 'a' => 'Tue'
# 'B' => 'June'
# 'b' => 'Jun'
# 'C' => '20'
# 'c' => 'Tue Jun 1 00:00:00 2010'
# 'D' => '06/01/10'
# 'd' => '01'
# 'E' => 'E'
# 'e' => ' 1'
# 'F' => '2010-06-01'
# 'f' => 'f'
# 'G' => '2010'
# 'g' => '10'
# 'H' => '00'
# 'h' => 'Jun'
# 'I' => '12'
# 'i' => 'i'
# 'J' => 'J'
# 'j' => '152'
# 'K' => 'K'
# 'k' => ' 0'
# 'L' => 'L'
# 'l' => '12'
# 'M' => '00'
# 'm' => '06'
# 'N' => 'N'
# 'n' => '
# '
# 'O' => 'O'
# 'o' => 'o'
# 'P' => 'P'
# 'p' => 'AM'
# 'Q' => 'Q'
# 'q' => 'q'
# 'R' => '00:00'
# 'r' => '12:00:00 AM'
# 'S' => '00'
# 's' => '1275364800'
# 'T' => '00:00:00'
# 't' => ' '
# 'U' => '22'
# 'u' => '2'
# 'V' => '22'
# 'v' => ' 1-Jun-2010'
# 'W' => '22'
# 'w' => '2'
# 'X' => '00:00:00'
# 'x' => '06/01/10'
# 'Y' => '2010'
# 'y' => '10'
# 'Z' => 'EDT'
# 'z' => '-0400'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment