dateparse icon indicating copy to clipboard operation
dateparse copied to clipboard

Cannot parse `2015-06-10 00:00:00 GMT+02:00`

Open kurilov opened this issue 7 years ago • 4 comments

Revision: 21df004e09ca46e07ce99bbba1e8c2422ba4ecf9 Example link: https://www.e-marketing.fr/Thematique/social-media-1096/Breves/Banque-Postale-mise-marketing-temps-reel-impression-255997.htm#WQ17awvif7mWRLVy.97 Test Case

func TestDateParse(t *testing.T) {
	_, err := dateparse.ParseAny("2015-06-10 00:00:00 GMT+02:00")
	assert.NoError(t, err)
}

Result


Error Trace:	date_extractor_test.go:80
Error:      	Received unexpected error:
	            	parsing time "2015-06-10 00:00:00 GMT+02:00" as "2006-01-02 15:04:05 MST-07000": cannot parse ":00" as "-0700"
Test:       	TestDateParse

kurilov avatar Dec 24 '18 14:12 kurilov

Do you mind clarifying for me is the "2015-06-10" October 6th 2015 or is that June 10th 2015, just to be absolutely sure.

araddon avatar Jan 02 '19 21:01 araddon

Hm, seems go doesn't really like that offset format (seems to not support the combo of GMT[+-]hh:mm ie with the colon?) https://play.golang.org/p/fjk2fFKNAwu

package main

import (
	"fmt"
	"time"
)

func main() {
	t, err := time.Parse("2006-01-02 15:04:05 MST-07:00","2015-10-06 00:00:00 GMT+02:00")
	fmt.Printf("1 t=%v   err=%v\n\n", t, err)
}

1 t=0001-01-01 00:00:00 +0000 UTC err=parsing time "2015-10-06 00:00:00 GMT+02:00" as "2006-01-02 15:04:05 MST-07:00": cannot parse ":00" as "-07:00"

araddon avatar Jan 02 '19 21:01 araddon

Yes, the problem is definitely in the format. :(

kurilov avatar Jan 17 '19 13:01 kurilov

I think I got it in my pr: https://github.com/araddon/dateparse/pull/151

arran4 avatar Feb 15 '23 22:02 arran4