简体   繁体   English

Ruby gem timecop 错误的旅行后两个日期之间的延迟

[英]Ruby gem timecop wrong delay between two dates after travel

I am using the helpful gem timecop ( https://github.com/travisjeffery/timecop ) for my tests with rspec and today an old unchanged test is breaking.我正在使用有用的 gem timecop ( https://github.com/travisjeffery/timecop ) 进行 rspec 的测试,今天一个旧的不变测试正在打破。

I might be mistaken in the way I am using it but using pry I printed the following:我可能在使用它的方式上弄错了,但是使用pry我打印了以下内容:

Time.zone.now => Wed, 31 Mar 2021 15:09:45 CEST +02:00
6.months.from_now => Thu, 30 Sep 2021 15:09:56 CEST +02:00
Timecop.travel(6.months.from_now)
Time.zone.now => Thu, 30 Sep 2021 15:10:10 CEST +02:00
6.months.ago => Tue, 30 Mar 2021 15:10:15 CEST +02:00

Thank you in advance for any idea to understand or solve this.预先感谢您提供任何了解或解决此问题的想法。

Have a nice day.祝你今天过得愉快。

Ok it is my mistake, there is no 31st in September so it falls back to 30th and then 6 months ago is 30th of March.好吧,这是我的错误,9 月没有 31 日,所以它回落到 30 日,然后 6 个月前是 3 月 30 日。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM