Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion time_zone_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ func ExampleTimeZone() {
}

fmt.Println(z.String())
fmt.Println(time.Time{}.In(z.Location()).Location().String())

// Location returns a *time.Location that can be applied to a time.Time.
loc := z.Location()
fmt.Println(time.Time{}.In(loc).Location().String())

// Output:
// America/New_York
// America/New_York
}

func ExampleTimeZone_zeroValue() {
// Loading "UTC" (or an empty string) always yields the zero value.
z, err := tz.LoadTimeZone("UTC")
if err != nil {
panic(err)
Expand Down Expand Up @@ -71,6 +75,7 @@ func ExampleTimeZone_Value() {
func ExampleTimeZone_Value_zeroValue() {
var z tz.TimeZone

// The zero value is stored as the "UTC" string, never as NULL.
v, err := z.Value()
fmt.Printf("%v %T %v\n", v, v, err)

Expand Down
7 changes: 7 additions & 0 deletions time_zone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,13 @@ func TestTimeZone_Scan(t *testing.T) {
wantTimeZone: mustLoadTimeZone(t, "America/New_York"),
wantErr: true,
},
{
name: "unsupported_type",
giveTimeZone: mustLoadTimeZone(t, "America/New_York"),
value: []int{1},
wantTimeZone: mustLoadTimeZone(t, "America/New_York"),
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
Loading