dateparse
dateparse copied to clipboard
Different timezone used with dateparse.RetryAmbiguousDateWithSwap(true) option.
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).
https://github.com/araddon/dateparse/blob/6b43995a97dee4b2c7fc0bdff8e124da9f31a57e/parseany.go#L253
@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.