Skip to content

Instantly share code, notes, and snippets.

@sunchen115
Last active September 18, 2017 03:30
Show Gist options
  • Save sunchen115/894e96953b44d8f594a6e174643f8ece to your computer and use it in GitHub Desktop.
Save sunchen115/894e96953b44d8f594a6e174643f8ece to your computer and use it in GitHub Desktop.
require 'date'
def days_between(date1, date2)
d1 = Date.parse(date1)
d2 = Date.parse(date2)
(d2 - d1).to_i
end
def choose_users(day_offset)
(day_offset/7)%2
end
def offset(day_offset)
day_offset % 7
end
def choose_user(now)
users1 = %w(文婷 雨辰 陈雨 孙晨 卉卉)
users = [users1]
day_offset = days_between("2017-05-08", now)
users1[offset(day_offset)]
end
choose_user(Time.now.to_s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment