travisjeffery / timecop

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.
MIT License
3.36k stars 223 forks source link

Fix %Y date format %Y #379

Closed joshuacronemeyer closed 2 years ago

joshuacronemeyer commented 2 years ago

Potential fix for https://github.com/travisjeffery/timecop/issues/377

augustoccesar commented 2 years ago

Since you mentioned the place where formats are listed as todo: https://github.com/travisjeffery/timecop/blob/8ca1018694fd9f906c95d92e4b90e5fe1be4429e/test/date_strptime_scenarios.rb#L68-L81 Do you think it would have value to add the format %Y to the supported list?

Other than that LGMT! 👍

joshuacronemeyer commented 2 years ago

Since you mentioned the place where formats are listed as todo:

https://github.com/travisjeffery/timecop/blob/8ca1018694fd9f906c95d92e4b90e5fe1be4429e/test/date_strptime_scenarios.rb#L68-L81

Do you think it would have value to add the format %Y to the supported list? Other than that LGMT! 👍

Thanks for looking. I actually realized that test will only work for date formats that are fully specified dates. It's converting from a specific date to a string and back to the date, but in the case of this date format where it's just the Year that doesn't work.