I'm getting tired of trying to figure out what day of quarantine it is, especially since I've been busy lately and haven't been getting around to posting my dailies until a day or two later. So here's some simple Ruby code to help figure out what day it is:
Then if you want to know what day of quarantine is is/will be on a certain date you can do this:
Or vice versa:
Yes, yes, I know that I have way too many parentheses. I've been writing Python for the past few weeks, and switching back and forth is hard on my brain.
require 'date' def what_day_is_it(arg) day_zero = Date.parse('2020-03-17') if arg.is_a?(Numeric) puts day_zero += arg elsif arg.is_a?(String) puts (Date.parse(arg) - day_zero).to_i end end
Then if you want to know what day of quarantine is is/will be on a certain date you can do this:
what_day_is_it('2020-05-18') 62
Or vice versa:
what_day_is_it(62) 2020-05-18
Yes, yes, I know that I have way too many parentheses. I've been writing Python for the past few weeks, and switching back and forth is hard on my brain.
Comments
Post a Comment