Skip to content

Commit c9a2829

Browse files
Restore duration string conversion supported suffixes (#459)
1 parent 6e3b3e0 commit c9a2829

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

doc/langdef.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,6 +2062,23 @@ double("3.14") // 3.14 (if successful, otherwise an error)
20622062

20632063
**duration**
20642064

2065+
Type conversion for duration values.
2066+
2067+
Note, duration strings should support the following suffixes:
2068+
2069+
* "h" (hour)
2070+
* "m" (minute)
2071+
* "s" (second)
2072+
* "ms" (millisecond)
2073+
* "us" (microsecond)
2074+
* "ns" (nanosecond)
2075+
2076+
Duration strings may be zero (`"0"`), negative (`-1h`), fractional (`-23.4s`),
2077+
and/or compound (`1h34us`). Durations greater than the hour granularity, such
2078+
as days or weeks, are not supported as this would necessitate an understanding
2079+
of the locale of the execution context to account for leap seconds and leap
2080+
years.
2081+
20652082
**Signatures:**
20662083

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

20722089
```
20732090
duration("1h30m") // google.protobuf.Duration representing 1 hour and 30 minutes
2091+
duration("0") // zero duration value
2092+
duration("-1.5h") // minus 90 minutes
20742093
```
20752094

20762095
**dyn** `type(dyn)` \- Type denotation

0 commit comments

Comments
 (0)