This generic code will parse any period using a facet to to get the 'elements'. For example, in the case of a date_period the elements will be instances of a date which will be parsed according the to setup in the passed facet parameter.

The steps for parsing a period are always the same:

consume the start delimiter

get start element

consume the separator

get either last or end element depending on range settings

consume the end delimeter depending on range settings

Thus for a typical date period the contents of the input stream might look like this: