Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Restore duration string conversion supported suffixes
  • Loading branch information
TristonianJones committed Apr 3, 2025
commit f39af1a37cfb293d619b20235f8cb23aca87a1fa
19 changes: 19 additions & 0 deletions doc/langdef.md
Original file line number Diff line number Diff line change
Expand Up @@ -2062,6 +2062,23 @@ double("3.14") // 3.14 (if successful, otherwise an error)

**duration**

Type conversion for duration values.

Note, duration strings should support the following suffixes:

* "h" (hour)
* "m" (minute)
* "s" (second)
* "ms" (millisecond)
* "us" (microsecond)
* "ns" (nanosecond)

Duration strings may be zero (`"0"`), negative (`-1h`), fractional (`-23.4s`),
and/or compound (`1h34us`). Durations greater than the hour granularity, such
as days or weeks, are not supported as this would necessitate an understanding
of the locale of the execution context to account for leap seconds and leap
years.

**Signatures:**

* `duration(google.protobuf.Duration) -> google.protobuf.Duration`
Expand All @@ -2071,6 +2088,8 @@ double("3.14") // 3.14 (if successful, otherwise an error)

```
duration("1h30m") // google.protobuf.Duration representing 1 hour and 30 minutes
duration("0") // zero duration value
duration("-1.5h") // minus 90 minutes
```

**dyn** `type(dyn)` \- Type denotation
Expand Down