@@ -90,14 +90,21 @@ func ExampleDuration_Truncate() {
90
90
func ExampleParseDuration () {
91
91
hours , _ := time .ParseDuration ("10h" )
92
92
complex , _ := time .ParseDuration ("1h10m10s" )
93
+ micro , _ := time .ParseDuration ("1µs" )
94
+ // The package also accepts the incorrect but common prefix u for micro.
95
+ micro2 , _ := time .ParseDuration ("1us" )
93
96
94
97
fmt .Println (hours )
95
98
fmt .Println (complex )
96
- fmt .Printf ("there are %.0f seconds in %v\n " , complex .Seconds (), complex )
99
+ fmt .Printf ("There are %.0f seconds in %v.\n " , complex .Seconds (), complex )
100
+ fmt .Printf ("There are %d nanoseconds in %v.\n " , micro .Nanoseconds (), micro )
101
+ fmt .Printf ("There are %6.2e seconds in %v.\n " , micro2 .Seconds (), micro )
97
102
// Output:
98
103
// 10h0m0s
99
104
// 1h10m10s
100
- // there are 4210 seconds in 1h10m10s
105
+ // There are 4210 seconds in 1h10m10s.
106
+ // There are 1000 nanoseconds in 1µs.
107
+ // There are 1.00e-06 seconds in 1µs.
101
108
}
102
109
103
110
func ExampleDuration_Hours () {
@@ -115,18 +122,14 @@ func ExampleDuration_Minutes() {
115
122
func ExampleDuration_Nanoseconds () {
116
123
u , _ := time .ParseDuration ("1µs" )
117
124
fmt .Printf ("One microsecond is %d nanoseconds.\n " , u .Nanoseconds ())
118
- // The package also accepts the incorrect but common prefix u for micro.
119
- v , _ := time .ParseDuration ("1us" )
120
- fmt .Printf ("One microsecond is %6.2e seconds.\n " , v .Seconds ())
121
125
// Output:
122
126
// One microsecond is 1000 nanoseconds.
123
- // One microsecond is 1.00e-06 seconds.
124
127
}
125
128
126
129
func ExampleDuration_Seconds () {
127
130
m , _ := time .ParseDuration ("1m30s" )
128
- fmt .Printf ("take off in t-%.0f seconds." , m .Seconds ())
129
- // Output: take off in t-90 seconds.
131
+ fmt .Printf ("Take off in t-%.0f seconds." , m .Seconds ())
132
+ // Output: Take off in t-90 seconds.
130
133
}
131
134
132
135
var c chan int
0 commit comments