Add support for repeated timestamps and durations to to_dict from_dict (#211)

This commit is contained in:
Matthew Badger
2021-02-16 18:54:50 +00:00
committed by GitHub
parent 59f5f88c0d
commit 9e6881999e
4 changed files with 44 additions and 3 deletions

View File

@@ -0,0 +1,4 @@
{
"times": ["1972-01-01T10:00:20.021Z", "1972-01-01T10:00:20.021Z"],
"durations": ["1.200s", "1.200s"]
}

View File

@@ -0,0 +1,10 @@
syntax = "proto3";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
message Test {
repeated google.protobuf.Timestamp times = 1;
repeated google.protobuf.Duration durations = 2;
}

View File

@@ -0,0 +1,9 @@
from datetime import datetime, timedelta
from tests.output_betterproto.repeated_duration_timestamp import Test
def test_roundtrip():
message = Test()
message.times = [datetime.now(), datetime.now()]
message.durations = [timedelta(), timedelta()]