-
Notifications
You must be signed in to change notification settings - Fork 16.1k
Description
What version of protobuf and what language are you using?
Version: v3.7.0
Language: Ruby
What operating system (Linux, Windows, ...) and version?
Windows 10
What runtime / compiler are you using (e.g., python version or gcc version)
Ruby 2.6.1
What did you do?
Install latest google-cloud-pubsub and google-protobuf gems, and run this code:
require "google/cloud/pubsub/v1"
now = Time.now
now_ts = Google::Protobuf::Timestamp.new seconds: now.to_i, nanos: now.nsec
msg = Google::Cloud::PubSub::V1::PubsubMessage.new publish_time: now_ts
msg.to_json #=> "{\"attributes\":{},\"publishTime\":\"2019-03-13T15:40:43.729054800Z\"}"
decoded_msg = Google::Cloud::PubSub::V1::PubsubMessage.decode_json msg.to_json
#=> Traceback (most recent call last):
# 1: from pubsub.rb:9:in `<main>'
# pubsub.rb:9:in `decode_json': Error occurred during parsing: error parsing timestamp: mingw doesn't support strptime (Google::Protobuf::ParseError)What did you expect to see
The ability to create a new protobuf resource object by decoding JSON that contains a timestamp.
What did you see instead?
A Google::Protobuf::ParseError error.
Anything else we should know about your project / environment
This appears to only happen on Windows, and it looks intentional. But Ruby will parse the timestamp string without issue, so I don't see why Windows couldn't use Time.parse instead of strptime.
require "time"
time_obj = Time.parse "2019-03-13T15:40:43.729054800Z"
timestamp_obj = Google::Protobuf::Timestamp.new seconds: time_obj.to_i, nanos: time_obj.nsec