Skip to content

Instantly share code, notes, and snippets.

@donat-b
Created February 1, 2015 19:12
Show Gist options
  • Save donat-b/ff7b35ac530c4e8a4ed6 to your computer and use it in GitHub Desktop.
Save donat-b/ff7b35ac530c4e8a4ed6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Generates list of dates according to a format passed as an argument
# Example: date-listgen.rb '%Y-%m-%d'
# 2015-02-01
require 'date'
def list_dates(format)
if format.nil?
format = '%d%m%Y'
end
d = Date.new(1900,1,1)
today = Date.today
begin
d = d + 1
puts d.strftime(format)
end until d == today
end
list_dates(ARGV[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment