A gem providing "time travel", "time freezing", and "time acceleration" capabilities, making it simple to test time-dependent code. It provides a unified method to mock Time.now, Date.today, and DateTime.now in a single call.
While trying to get the rest of the TODO date formats to work I found a bug with the previous week based date handling. If we were given a date like Date.strptime('2006 23 0', '%Y %U %w') our code would come up with 2006/6/11. But it is actually 2006/6/4
The problem is that we were trying to use Date.commercial for everything but some weeks a given sunday based date isn't even in the same week as the monday based weeks that Date.commercial uses. See below. 6/4 is in the 22nd commercial week but 23rd non-commercial
I'm proposing this alternative implementation where we delegate to the unmocked strptime but pass it a fully qualified date string that is populated from our mocked time where appropriate. This is now working for all the TODO date formats. I'm not crazy about this implementation since it feels icky to have this one scenario where we are using strptime to compute the new date. Without having something like Date.non_commercial that takes the sunday based weeks I'm not sure what else to do.
While trying to get the rest of the TODO date formats to work I found a bug with the previous week based date handling. If we were given a date like Date.strptime('2006 23 0', '%Y %U %w') our code would come up with 2006/6/11. But it is actually 2006/6/4
The problem is that we were trying to use Date.commercial for everything but some weeks a given sunday based date isn't even in the same week as the monday based weeks that Date.commercial uses. See below. 6/4 is in the 22nd commercial week but 23rd non-commercial
I'm proposing this alternative implementation where we delegate to the unmocked strptime but pass it a fully qualified date string that is populated from our mocked time where appropriate. This is now working for all the TODO date formats. I'm not crazy about this implementation since it feels icky to have this one scenario where we are using strptime to compute the new date. Without having something like Date.non_commercial that takes the sunday based weeks I'm not sure what else to do.