Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regarding “time_difference" #22

Open
Giriraj24 opened this issue Sep 12, 2016 · 2 comments
Open

Regarding “time_difference" #22

Giriraj24 opened this issue Sep 12, 2016 · 2 comments

Comments

@Giriraj24
Copy link

Hi Lee,

I hope you are doing great.

I needed small help regarding: https://rubygems.org/gems/time_difference/versions/0.4.2

I was trying to use “time_difference” in my ruby script, however was getting below error:

ghe_premerge_onboard.rb:47:in block in <main>': uninitialized constant TimeDifference (NameError) from ghe_premerge_onboard.rb:41:ineach'
from ghe_premerge_onboard.rb:41:in `

Btw,

I added following require statement in my ruby script:

require ‘time_difference’

But it throws the error for that as well? Is that correct require statement to use it in ruby script?

Also I was trying to use following way:

pom_repo.each do |repos|
commit_date = client.repository("#{orgname}/#{repos}").pushed_at
date_now = Time.now
today_date = date_now.utc
puts TimeDifference.between(commit_date, today_date).in_months
end

Please help

Thanks,
Giriraj

@Shwetakale
Copy link

@Giriraj24 Which ruby version you are using? I hope your current execution environment have time_difference installed.

You can check it using

shweta $ gem which time_difference
/home/shweta/.rvm/gems/ruby-2.1.2/gems/time_difference-0.4.2/lib/time_difference.rb

I am using ruby version 2.1.2 and I don't see any issue,

2.1.2 :003 >   require 'time_difference'
=> true 
2.1.2 :004 > commit_date = Date.yesterday
=> Sun, 11 Sep 2016 
2.1.2 :005 > date_now = Time.now
 => 2016-09-12 22:31:25 +0530 
2.1.2 :006 > today_date = date_now.utc
=> 2016-09-12 17:01:25 UTC 
2.1.2 :007 > puts TimeDifference.between(commit_date, today_date).in_months
0.06
=> nil 

@tmlee
Copy link
Owner

tmlee commented Feb 25, 2017

@Giriraj24 I concur with trying out the suggestion from @Shwetakale
To make things cleaner, suggest using https://rvm.io/ and install a clean new version of Ruby
Then install the time_difference gem and require it from there and see if the problem still occur

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants