Skip to content

Instantly share code, notes, and snippets.

@AhnSeongHyun
Created June 10, 2012 05:42
Show Gist options
  • Save AhnSeongHyun/2903986 to your computer and use it in GitHub Desktop.
Save AhnSeongHyun/2903986 to your computer and use it in GitHub Desktop.
[RUBY]DayOfWeek
def checkMonday()
time = Time.new;
year = time.year;
month = time.month;
day = time.day;
year1_int = year.to_s.slice(0..1).to_i;
year2_int = year.to_s.slice(2..3).to_i;
if month.to_i <= 2 then
refined_mm = month.to_i+12;
refined_dd = day+1;
else
refined_mm = month.to_i;
refined_dd = day
end
result = ((21*year1_int.to_i/4) + (5*year2_int.to_i/4) + (26*(refined_mm.to_i+1)/10)+ refined_dd.to_i-1)%7
return result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment