Skip to content

Commit

Permalink
Clarify requirements of strict date formats. (#29090)
Browse files Browse the repository at this point in the history
Closes #29014
  • Loading branch information
jpountz authored Mar 16, 2018
1 parent 695ec05 commit 0755ff4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions docs/reference/mapping/params/format.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,18 @@ http://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html[i
[[built-in-date-formats]]
==== Built In Formats

Most of the below dates have a `strict` companion dates, which means, that
year, month and day parts of the week must have prepending zeros in order
to be valid. This means, that a date like `5/11/1` would not be valid, but
you would need to specify the full date, which would be `2005/11/01` in this
example. So instead of `date_optional_time` you would need to specify
`strict_date_optional_time`.
Most of the below formats have a `strict` companion format, which means that
year, month and day parts of the week must use respectively 4, 2 and 2 digits
exactly, potentially prepending zeros. For instance a date like `5/11/1` would
be considered invalid and would need to be rewritten to `2005/11/01` to be
accepted by the date parser.

To use them, you need to prepend `strict_` to the name of the date format, for
instance `strict_date_optional_time` instead of `date_optional_time`.

These strict date formats are especially useful when
<<date-detection,date fields are dynamically mapped>> in order to make sure to
not accidentally map irrelevant strings as dates.

The following tables lists all the defaults ISO formats supported:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* class is named ISODatetimeFormat
*
* However there has been done one huge modification in several methods, which forces the date
* year to be at least n digits, so that a year like "5" is invalid and must be "0005"
* year to be exactly n digits, so that a year like "5" is invalid and must be "0005"
*
* All methods have been marked with an "// ES change" commentary
*
Expand Down

0 comments on commit 0755ff4

Please sign in to comment.