@@ -1029,6 +1029,17 @@ absl::Status DurationReflection::SetFromAbslDuration(
10291029 return absl::OkStatus ();
10301030}
10311031
1032+ void DurationReflection::UnsafeSetFromAbslDuration (
1033+ absl::Nonnull<google::protobuf::Message*> message, absl::Duration duration) const {
1034+ ABSL_DCHECK (IsInitialized ());
1035+ ABSL_DCHECK_EQ (message->GetDescriptor (), descriptor_);
1036+ int64_t seconds = absl::IDivDuration (duration, absl::Seconds (1 ), &duration);
1037+ int32_t nanos = static_cast <int32_t >(
1038+ absl::IDivDuration (duration, absl::Nanoseconds (1 ), &duration));
1039+ SetSeconds (message, seconds);
1040+ SetNanos (message, nanos);
1041+ }
1042+
10321043absl::StatusOr<absl::Duration> DurationReflection::ToAbslDuration (
10331044 const google::protobuf::Message& message) const {
10341045 ABSL_DCHECK (IsInitialized ());
@@ -1052,6 +1063,15 @@ absl::StatusOr<absl::Duration> DurationReflection::ToAbslDuration(
10521063 return absl::Seconds (seconds) + absl::Nanoseconds (nanos);
10531064}
10541065
1066+ absl::Duration DurationReflection::UnsafeToAbslDuration (
1067+ const google::protobuf::Message& message) const {
1068+ ABSL_DCHECK (IsInitialized ());
1069+ ABSL_DCHECK_EQ (message.GetDescriptor (), descriptor_);
1070+ int64_t seconds = GetSeconds (message);
1071+ int32_t nanos = GetNanos (message);
1072+ return absl::Seconds (seconds) + absl::Nanoseconds (nanos);
1073+ }
1074+
10551075absl::StatusOr<DurationReflection> GetDurationReflection (
10561076 absl::Nonnull<const Descriptor*> descriptor) {
10571077 DurationReflection reflection;
@@ -1132,6 +1152,15 @@ absl::Status TimestampReflection::SetFromAbslTime(
11321152 return absl::OkStatus ();
11331153}
11341154
1155+ void TimestampReflection::UnsafeSetFromAbslTime (
1156+ absl::Nonnull<google::protobuf::Message*> message, absl::Time time) const {
1157+ int64_t seconds = absl::ToUnixSeconds (time);
1158+ int32_t nanos = static_cast <int32_t >((time - absl::FromUnixSeconds (seconds)) /
1159+ absl::Nanoseconds (1 ));
1160+ SetSeconds (message, seconds);
1161+ SetNanos (message, nanos);
1162+ }
1163+
11351164absl::StatusOr<absl::Time> TimestampReflection::ToAbslTime (
11361165 const google::protobuf::Message& message) const {
11371166 int64_t seconds = GetSeconds (message);
@@ -1149,6 +1178,13 @@ absl::StatusOr<absl::Time> TimestampReflection::ToAbslTime(
11491178 return absl::UnixEpoch () + absl::Seconds (seconds) + absl::Nanoseconds (nanos);
11501179}
11511180
1181+ absl::Time TimestampReflection::UnsafeToAbslTime (
1182+ const google::protobuf::Message& message) const {
1183+ int64_t seconds = GetSeconds (message);
1184+ int32_t nanos = GetNanos (message);
1185+ return absl::UnixEpoch () + absl::Seconds (seconds) + absl::Nanoseconds (nanos);
1186+ }
1187+
11521188absl::StatusOr<TimestampReflection> GetTimestampReflection (
11531189 absl::Nonnull<const Descriptor*> descriptor) {
11541190 TimestampReflection reflection;
0 commit comments