augur.dates.ambiguous_date module

class augur.dates.ambiguous_date.AmbiguousDate(uncertain_date, fmt='%Y-%m-%d')

Bases: object

Transforms a date string with uncertainty into the range of possible dates.

assert_only_less_significant_uncertainty()

Raise an exception if a constrained digit appears in a less-significant place than an uncertain digit.

Assuming %Y-%m-%d, these patterns are valid:

2000-01-01 2000-01-XX 2000-XX-XX

but this is invalid, because month is uncertain but day is constrained:

2000-XX-01

These invalid cases are assumed to be unintended use of the tool.

property fmt_components
range(min_max_year=None)

Return the range of possible dates defined by the ambiguous date.

Impose an upper limit of today’s date.

property regex

Returns regex defined by the format string. Currently only supports %Y, %m, and %d.

property uncertain_date_components
augur.dates.ambiguous_date.get_bounds(min_max_year)

Get exact date bounds based on given years.

augur.dates.ambiguous_date.max_day_for_year_month(year, month)
augur.dates.ambiguous_date.resolve_uncertain_int(uncertain_string, min_or_max)

Takes a string representation of an integer with uncertain places occupied by the character X. Returns the minimum or maximum possible integer.

augur.dates.ambiguous_date.tuple_to_date(year, month, day)