Skip to content

Regarding “time_difference" #22

Description

@Giriraj24

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

Activity

  1. Shwetakale commented on Sep 12, 2016

    @Shwetakale

    @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 
    
  2. tmlee commented on Feb 25, 2017

    @tmlee
    Owner

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions