3

I am running into a uninitialized constant Context::DateTime error in Ruby. My code is:

# Print data about a list of Tweets
def print_timeline(tweets)
  tweets.each do |tweet|
    d = datetime.new(tweet['created_at'])
    puts "#{tweet['user']['name']} , #{tweet['text']} , #{d.strftime('%m.%d.%y')} , #{tweet['id']}"
  end
end

I believe it is saying it cannot find the DateTime class, and I am not sure why. I am new to Ruby.

4

1 回答 1

6

DateTime应该大写,就像你的问题的标题一样。此外,您可能需要添加:

require "date"
于 2013-06-12T12:37:36.517 回答