Why is date parsing dependent on delimiters?

Take the following two examples:

Date.parse("02/20/2009")
Date.parse("02-20-2009")

In the first example, the order is considered MM DD YYYY, but in the second example an error occurs because (I assume) he is trying to parse it as DD MM YYYY.

Why?

+3
source share
2 answers

"02/20/2009" is a date representation only in the local ru_US directory . "02-20-2009" is not intended to comply with the standard. There are two popular standards that are used everywhere except in the USA: DD-MM-YYYY or ISO 8601, which is YYYY-MM-DD.

http://en.wikipedia.org/wiki/File:Date.png

+10

โ€‹โ€‹ (, , ). Ruby , .

0

Source: https://habr.com/ru/post/1703671/


All Articles