Created
October 29, 2012 18:42
-
-
Save suryart/3975619 to your computer and use it in GitHub Desktop.
Travel Allowance Statement generation Script
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
t1 = (Time.now-6.months).beginning_of_month # Start Date Time | |
t2 = (Time.now).end_of_month # End Date and Time | |
t = t1 | |
amounts = [155, 140, 160] | |
from = "Banashankari 3rd Satge, Vyalikaval" | |
to = "Vyalikaval, Banashankari 3rd Satge" | |
month = t.month | |
year = t.year | |
leaves = {"26/01/2012" => "Republic Day", "23/03/2012" => "Chandramana Ugadi", "01/05/2012" => "May Day", "15/08/2012" => "Independence Day", "19/09/2012" => "Ganesha Chaturthi", "02/10/2012" => "Gandhi Jayanti", "23/10/2012" => "Audha Pooja", "01/11/2012" => "Kannada Rajyotsava", "12/11/2012" => "Naraka Chaturdashi", "14/11/2012" => "Balipadyami" } | |
puts "#{t.strftime("%B")} (#{t.strftime("%Y")}), From Location, To Location, Fare in INR" | |
while t <= t2 | |
if month != t.month || year != t.year | |
puts "#{t.strftime("%B")} (#{t.strftime("%Y")}), From Location, To Location, Fare in INR" | |
month = t.month | |
year = t.year | |
end | |
if t.sunday? | |
puts "#{t.strftime("%d/%m/%Y")}, Sunday" | |
elsif !leaves["#{t.strftime("%d/%m/%Y")}"].blank? | |
puts "#{t.strftime("%d/%m/%Y")}, Leave (#{leaves[t.strftime("%d/%m/%Y").to_s]})" | |
else | |
puts "#{t.strftime("%d/%m/%Y")}, #{from}, #{amounts[rand(0..2)]}" | |
puts "#{t.strftime("%d/%m/%Y")}, #{to}, #{amounts[rand(0..2)]}" | |
end | |
t = t+1.day | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment