dateparse icon indicating copy to clipboard operation
dateparse copied to clipboard

Request: Support for DD/MM/YYYY

Open matthewhartstonge opened this issue 8 years ago • 7 comments

Hello!

I noticed dateparse doesn't currently have support for UK based dates, is this within scope?

Flipped examples from mm/dd/yyyy:

	// dd/mm/yyyy
	"31/3/2014",
	"31/03/2014",
	"21/08/71",
	"1/8/71",
	"8/4/2014 22:05",
	"08/04/2014 22:05",
	"2/04/2014 03:00:51",
	"8/8/1965 12:00:00 AM",
	"8/8/1965 01:00:01 PM",
	"8/8/1965 01:00 PM",
	"8/8/1965 1:00 PM",
	"8/8/1965 12:00 AM",
	"4/02/2014 03:00:51",
	"19/03/2012 10:11:59",
	"19/03/2012 10:11:59.3186369",

matthewhartstonge avatar Aug 29 '17 09:08 matthewhartstonge

Let me play around and see what that would look like. Since dd/mm vs mm/dd are ambiguous for this state-machine, I think it would have to be declarative (different function name).

araddon avatar Aug 29 '17 14:08 araddon

Still working on this. Have finished refactor as precursor and will create an API to prefer DD/MM when ambigous.

araddon avatar Mar 15 '18 21:03 araddon

Internationally, dd/mm is way more common than mm/dd, right? Afaik, only the USA uses mm/dd, while the entire rest of the world uses mm/dd..

stevenroose avatar Mar 16 '18 11:03 stevenroose

According to WP, DMY is by far the most used format, then YMD, distantly followed by the remainder including MDY.

What about using the system timezone to set a default format?

alecthomas avatar Mar 17 '18 03:03 alecthomas

The current implementation of ParseStrict might be a bit more strict than it really needs to be. For date strings such as 13/08/2018, you can rule out any ambiguity because a) you have a 4-digit year, so you know which is the year part, and b) you know there's no month value greater than 12.

sworisbreathing avatar Sep 05 '18 02:09 sworisbreathing

I'm currently stuck on this one too.. What about exposing the preferMonthFirst setting?

kkesley avatar Nov 02 '18 02:11 kkesley

Hi, @matthewhartstonge

All the cases where the dd and mm is ambiguous are working correctly in my fix https://github.com/araddon/dateparse/pull/133

You can use my fork while it is waiting for a merge go get github.com/mehanizm/dateparse@ea6d70072703

mehanizm avatar Aug 09 '21 13:08 mehanizm