Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create a todo formated file for this year. Ref. http://easyramble.com/how-to-manage-tasks-simply.html
#!/usr/bin/env ruby
require "date"
def this_year
( ARGV[0] || DateTime.now.year ).to_i
end
def leap_year?
Date.new(this_year).leap?
end
def last_day
leap_year? ? 365 : 364
end
TODO_FILE_BASENAME = "DailyToDo"
gantan = DateTime.new(this_year, 1, 1, 0, 0, 0, "+0900")
todo_file = "./#{TODO_FILE_BASENAME}_#{this_year}.txt"
if File.exist?(todo_file)
warn "Todo file was not created. This year's todo file already exists."
exit
end
open(todo_file, "w") do |f|
f.write <<EOS
***************** #{TODO_FILE_BASENAME} #{this_year} *****************
- : todo
= : doing
+ : done
**************************************************
EOS
(0..last_day).each do |d|
f.write "[#{(gantan + d).strftime("%Y/%m/%d %A")}]\n\n"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.