Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different timezone used with dateparse.RetryAmbiguousDateWithSwap(true) option. #161

Open
jozuenoon opened this issue Apr 3, 2024 · 1 comment

Comments

@jozuenoon
Copy link

When running the below test time zone is not consistent:

func TestDateParseOptions(t *testing.T) {
	t0, err := dateparse.ParseAny("21/09/2010", dateparse.RetryAmbiguousDateWithSwap(true))
	require.NoError(t, err)

	t1, err := dateparse.ParseAny("09/21/2010", dateparse.RetryAmbiguousDateWithSwap(true))
	require.NoError(t, err)

	require.Equal(t, t0, t1)
}

   -(time.Time) 2010-09-21 00:00:00 +0200 CEST
   +(time.Time) 2010-09-21 00:00:00 +0000 UTC

I guess this is due to this line (below) using time.Local instead of the loc variable. If anyone can guide me if this is somehow intentional or can be changed (I can create a merge request).

p, err = parseTime(datestr, time.Local, modifiedOpts...)

@klondikedragon
Copy link

@jozuenoon -- this bug is fixed in the fork of this package https://pkg.go.dev/github.com/itlightning/dateparse (we're trying to maintain this package) -- I verified that your example test case already passes in the forked package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants