Would you say this is normal?
I just downloaded the gem and I'm executing from inside a Rails app
irb(main):001:0> Faker::Time.between(5.minutes.from_now, 10.minutes.from_now)
=> 2018-06-12 00:29:37 +0700
irb(main):002:0> Faker::Time.between(5.minutes.from_now, 10.minutes.from_now)
=> 2018-06-12 06:50:27 +0700
irb(main):003:0> Faker::Time.between(5.minutes.from_now, 10.minutes.from_now)
=> 2018-06-12 17:44:16 +0700
irb(main):004:0> Faker::Time.between(5.minutes.from_now, 10.minutes.from_now)
=> 2018-06-12 09:25:23 +0700
I want an interval of 5 minutes and I got a few hours interval.
The output of 5.minutes.from_now and 10.minutes.from_now is correct
irb(main):005:0> 5.minutes.from_now
=> Tue, 12 Jun 2018 16:14:44 UTC +00:00
irb(main):006:0> 10.minutes.from_now
=> Tue, 12 Jun 2018 16:19:52 UTC +00:00
@microweb10 Have you already tried Faker::Time.between(5.minutes.from_now, 10.minutes.from_now, :between)?
The command above solves your problem, but I don't know if it makes sense to have period = :all as a standard value in this method because this case is used when we are working with dates. If we use :all, we should get a sample of an hour in the provided day, that's why you were getting invalid values. I think period should be set as :between and if we want to use :all, we should pass it as a parameter. What do you think?
Exactly! Especially in a method called "between".
Also not referenced here in the documentation, where we can see instead:
# Random date between dates
Faker::Time.between(DateTime.now - 1, DateTime.now) #=> "2014-09-18 12:30:59 -0700"
If I first read this. I expect to get a datetime between the 2 Times.
Hello,
I'd suggest to remove the deprecation warning until you add the fix because it's pretty invasive in tests reports ;)
The deprecation was removed in 35f4418d. This issue will be addressed in v2.
I would like to work on this but I don't see a v2 branch to target. Would it be okay if I made a PR for this anyway?
I have created a v2 branch for you to target. :)
Nice, thanks. I looked at the old PRs and I was going to suggest we do the following:
period completely from Faker::Time::between and make it behave more like Faker::Date::between, respecting the boundaries of from and to Faker::Time::between_dates(from, to, period: :all, format = nil) that will behave like the current method does, except that the period :between will no longer have a meaning.What do you think?
I'm all for consistency :)
Most helpful comment
Hello,
I'd suggest to remove the deprecation warning until you add the fix because it's pretty invasive in tests reports ;)