質問

I have a Tweet object from the twitter gem, called @tweet.

I am able to do:

@tweet.created_at --> `@tweet.created_at.class` outputs `Time`

However, I want to change the timezone of created_at, so I tried:

@tweet.created_at.utc

And got:

can't modify frozen Time

How would I change from UTC−08:00 that my current created_at is, to CET time?

役に立ちましたか?

解決

Since the created_at time field of the tweet has been frozen, you can't modify it, so utc will raise the Exception, because it tries to change value of self. Instead of modification you shell to duplicate the variable and reassign it:

@tweet.created_at = @tweet.created_at.dup.utc
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top