NAME
Protobuf::WKT::Duration - Mixin for google.protobuf.Duration
VERSION
version 0.04
SYNOPSIS
# In your .proto
import "google/protobuf/duration.proto";
message MyEvent {
google.protobuf.Duration elapsed = 1;
}
# In your Perl code
my $event = MyEvent->new;
my $duration = $event->elapsed;
# Setting from seconds
$duration->from_seconds(1.5);
# $duration->seconds is 1, $duration->nanos is 500,000,000
# Getting total seconds
my $total_seconds = $duration->to_seconds(); # Returns 1.5
DESCRIPTION
This module provides helper methods for the generated class corresponding to the google.protobuf.Duration Well-Known Type. These methods are injected into the Protobuf::WKT::Duration class, which should be automatically used when google/protobuf/duration.proto is processed.
The Duration type represents a signed, fixed-length span of time.
METHODS
to_seconds()
Returns the total duration in seconds as a floating-point number (seconds + nanos / 1e9).
from_seconds($seconds)
Sets the seconds and nanos fields from a total number of seconds (can be fractional).
Returns $self for chaining.
get_injected_methods()
Internal method used by Protobuf::ClassGenerator to list methods to inject into the class.
SEE ALSO
AUTHOR
C.J. Collier <cjac@google.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Google LLC.
This is free software; you can redistribute it and/or modify it under the terms of the BSD 3-Clause License.