Skip to content

time: fix for "AddDate() should use UTC if loc is nil" does not seem to actually fix the issue #23048

@tve

Description

@tve

The fix for issue #15852 time: AddDate() should use UTC if loc is nil does not seem to actually fix things. See the following snipped in golang play:

package main

import "fmt"
import "time"

func main() {
	t1 := time.Date(2017, 1, 1, 0, 0, 0, 0, time.UTC)
	fmt.Printf("%+v\n", struct{s time.Time}{t1})
	t2 := t1.AddDate(0,0,0)
	fmt.Printf("%+v\n", struct{s time.Time}{t2})
}

results in

{s:{wall:0 ext:63618825600 loc:<nil>}}
{s:{wall:0 ext:63618825600 loc:<nil>}}

See https://play.golang.org/p/InvEKjzB5b

Supposedly this was fixed in https://go-review.googlesource.com/c/go/+/23561
Am I missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions