Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Time Blocks for Ruby

Tags:

ruby

I have a ruby app that I have developed that archives and backs up my files. What I'm trying to do is have it backup at the end of each month all files for that month, e.i on March 31 backup all files with March time stamps. Apart from me writing regex to do this does anyone know a better way of handling this?

like image 370
rahrahruby Avatar asked Dec 19 '25 17:12

rahrahruby


1 Answers

Use Date ranges:

(Date.new(2012, 2, 1)..Date.new(2012,2,29)).include? Date.new(2012, 2, 23) 
#=> true
(Date.new(2012, 2, 1)..Date.new(2012,2,29)).include? Date.new(2012, 3, 23) 
#=> false
like image 58
Michael Kohl Avatar answered Dec 22 '25 11:12

Michael Kohl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!