Skip to content

Commit 3c69897

Browse files
authored
Merge pull request #4 from timonwong/example-test
Add example test
2 parents 30b8828 + 22749e9 commit 3c69897

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

example_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package strftime
2+
3+
import (
4+
"fmt"
5+
"time"
6+
)
7+
8+
func ExampleFormat() {
9+
t := time.Date(2008, 9, 3, 20, 4, 26, 654321000, time.FixedZone("CST", 8*3600))
10+
11+
fmt.Println(Format(t, "%c"))
12+
fmt.Println(Format(t, "%Y-%m-%dT%H:%M:%S.%f%z"))
13+
fmt.Println(Format(t, "%A is day number %w of the week."))
14+
fmt.Println(Format(t, "Last century was%n the %Cth century."))
15+
fmt.Println(Format(t, "Time zone: %Z"))
16+
17+
// Output:
18+
// Wed Sep 3 20:04:26 2008
19+
// 2008-09-03T20:04:26.654321+0800
20+
// Wednesday is day number 3 of the week.
21+
// Last century was
22+
// the 20th century.
23+
// Time zone: CST
24+
}

0 commit comments

Comments
 (0)