Dates
Dates are given in a basic ISO 8601 date or date-time format, YYYY-MM-DD
or YYYY-MM-DDTHH:MM:SS
.
In source data, we find varying degrees of precision: some events may be defined as a full timestamp (2021-08-25T09:26:11
), while for many we only know a year (2021
) or month (2021-08
). Such date prefixes are carried through and used to specify date precision as well as the actual value.
In the future, FtM may include support for approximate dates (~1968
), and date ranges (1968-03 -- 1973-01
).
Attribute | Value | Detail |
---|---|---|
name | date |
Used in schema definitions |
label | Date | plural: Dates |
group | dates |
Used in search indexing to query all properties of a given type |
matchable | Suitable for use in entity matching | |
pivot | Suitable for use as a pivot point for connecting to other entities |
Temporal extent
Many schema include annotations that select properties which define the temporal start and end information for a given entity type: for example, an Ownership
may have a startDate
and endDate
, a Company
a incorporationDate
and dissolutionDate
, and a Person
a birthDate
and deathDate
.
Temporal extents are meant to provide semantics that help to project entity information into timelines.
Python API
Date validation and handling in Python is performed using the prefixdate Python library, which may eventually be subsumed in rigour
.
followthemoney.types.DateType
Bases: PropertyType
A date or time stamp. This is based on ISO 8601, but meant to allow for different
degrees of precision by specifying a prefix. This means that 2021
, 2021-02
,
2021-02-16
, 2021-02-16T21
, 2021-02-16T21:48
and 2021-02-16T21:48:52
are all valid values, with an implied precision.
The timezone is always expected to be UTC and cannot be specified otherwise. There is
no support for calendar weeks (2021-W7
) and date ranges (2021-2024
).
Source code in followthemoney/types/date.py
clean_text(text, fuzzy=False, format=None, proxy=None)
The classic: date parsing, every which way.
Source code in followthemoney/types/date.py
to_datetime(value)
Convert a date string to a datetime object in UTC for handling in Python. This
will convert the unset fields beyond the prefix to the first possible value, e.g.
2021-02
will become 2021-02-01T00:00:00Z
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
The date string to convert. |
required |
Returns:
Type | Description |
---|---|
Optional[datetime]
|
Optional[datetime]: The parsed datetime object in UTC, or None if parsing fails. |
Source code in followthemoney/types/date.py
to_number(value)
Convert a date string to a number, which is the number of seconds since the epoch (1970-01-01T00:00:00Z).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
The date string to convert. |
required |
Returns:
Type | Description |
---|---|
Optional[float]
|
Optional[float]: The timestamp as a float, or None if parsing fails. |
Source code in followthemoney/types/date.py
validate(value, fuzzy=False, format=None)
Check if a thing is a valid date.