diff --git a/ruby/lib/google/protobuf/well_known_types.rb b/ruby/lib/google/protobuf/well_known_types.rb index 2ee65bc267..37f8d5b675 100644 --- a/ruby/lib/google/protobuf/well_known_types.rb +++ b/ruby/lib/google/protobuf/well_known_types.rb @@ -72,8 +72,14 @@ module Google end Timestamp.class_eval do - def to_time - Time.at(self.to_f) + if RUBY_VERSION < "2.5" + def to_time + Time.at(self.to_f) + end + else + def to_time + Time.at(seconds, nanos, :nanosecond) + end end def from_time(time)