diff options
author | Pantelis Sampaziotis <psampaz@gmail.com> | 2019-09-17 19:01:36 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2019-09-17 20:11:12 +0000 |
commit | 575386d6324308d83f6f0782e61620ffe9f5dba3 (patch) | |
tree | f7e4224509b71dd7e85cfd7b92f7ce66df46f0d3 /src/time/example_test.go | |
parent | 06e5529eceae35bb26b51f2430c2c9425149ede2 (diff) | |
download | go-575386d6324308d83f6f0782e61620ffe9f5dba3.tar.gz go-575386d6324308d83f6f0782e61620ffe9f5dba3.zip |
time: add examples for microseconds and milliseconds methods
This change adds testable examples for the new Microseconds and Milliseconds methods that were introduced in Go 1.13.
Fixes #34354
Change-Id: Ibdbfd770ca2192f9086f756918325f7327ce0482
GitHub-Last-Rev: 4575f48f5feb8e49742304d17776e28302647931
GitHub-Pull-Request: golang/go#34355
Reviewed-on: https://go-review.googlesource.com/c/go/+/195979
Reviewed-by: Alexander Rakoczy <alex@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/time/example_test.go')
-rw-r--r-- | src/time/example_test.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/time/example_test.go b/src/time/example_test.go index 25c34ebc1c..4d70471a7d 100644 --- a/src/time/example_test.go +++ b/src/time/example_test.go @@ -113,6 +113,20 @@ func ExampleDuration_Hours() { // Output: I've got 4.5 hours of work left. } +func ExampleDuration_Microseconds() { + u, _ := time.ParseDuration("1s") + fmt.Printf("One second is %d microseconds.\n", u.Microseconds()) + // Output: + // One second is 1000000 microseconds. +} + +func ExampleDuration_Milliseconds() { + u, _ := time.ParseDuration("1s") + fmt.Printf("One second is %d milliseconds.\n", u.Milliseconds()) + // Output: + // One second is 1000 milliseconds. +} + func ExampleDuration_Minutes() { m, _ := time.ParseDuration("1h30m") fmt.Printf("The movie is %.0f minutes long.", m.Minutes()) |