module timelinelib.config.dateformatparser

The DateFormatParser is used define how a date string shall be parsed, given a pattern describing the date format.

The date format string shall contain three regions (YEAR, MONTH, DAY) with two region separators in between.

Tests are found here.

timelinelib.config.dateformatparser.REGION_START_POS = 0
timelinelib.config.dateformatparser.REGION_LENGTH = 1
timelinelib.config.dateformatparser.REGION_SEPARATOR = 2
timelinelib.config.dateformatparser.REGION_TYPE = 3
timelinelib.config.dateformatparser.YEAR = 'YEAR'
timelinelib.config.dateformatparser.MONTH = 'MONTH'
timelinelib.config.dateformatparser.DAY = 'DAY'
timelinelib.config.dateformatparser.ERROR_TEXT = "Invalid Date Format:\n\nThe format should contain\n one year placeholder = yyyy\n one month placeholder = mmm or mm\n one day placeholder = dd\n two placeholders for separators between year, month and day\n\nSeparators can't contain the letters y, m or d\n\nExample of valid formats:\n yyyy-mm-dd\n dd/mm/yyyy\n mmm/dd-yyyy\n "
class timelinelib.config.dateformatparser.DateFormatParser[source]

Bases: object

get_error_text()[source]

Returns a text that describes how a valid date format string shall be constructed.

is_valid(date_format)[source]

Return True if the given date_format is a valid format.

parse(date_format)[source]

Parse the date format string, and retrieve region information.

get_separators()[source]

Return a 2 item tuple with the region separators.

get_region_order()[source]

Return the index of the year, mont and day region orders.

use_abbreviated_month_names()[source]

If the length of the MONTH region contains 3 characters abbreviated month names shall be used.