Skip to content

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

@jozuenoon

Description

@jozuenoon

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...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions