Commit 575386d6 authored by Pantelis Sampaziotis's avatar Pantelis Sampaziotis Committed by Ian Lance Taylor

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/+/195979Reviewed-by: default avatarAlexander Rakoczy <alex@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 06e5529e
......@@ -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())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment