PartialDate#
- class documenteer.citations.PartialDate(year, month=None, day=None)#
Bases:
objectA publication date stated to the precision its source knows.
A bibliographic source rarely states a full day. A
.bibfile, a journal’s front matter, and a CITATION.cff reference commonly give a year alone, and DataCite’s own mandatory metadata is apublicationYear. Carrying such a date as adatetime.datewould mean inventing a month and a day — and since Documenteer publishes the date as schema.orgdatePublished, the invented day would then be asserted as fact on every page of a site. ISO 8601 spells reduced precision asYYYYandYYYY-MM, schema.orgDateis ISO 8601, and DataCite’s crosswalk mapspublicationYearontodatePublishedas a bare year; this type is that spelling.A rendered citation shows only the year at every precision, so stating a date to the year costs a reader nothing: only the machine-readable metadata tells the three precisions apart.
Attributes Summary
The day, when the source states one.
The month, when the source states one.
The publication year.
Methods Summary
from_date(value)Express a full calendar date at day precision.
Express the date as ISO 8601 at its own precision.
parse(value)Read a date written as
YYYY,YYYY-MM, orYYYY-MM-DD.to_date()Express the date as a
datetime.date, when it states a full one.Attributes Documentation
Methods Documentation
- classmethod from_date(value)#
Express a full calendar date at day precision.
- Parameters:
value (
date) – The date.- Returns:
The same date, stated to the day.
- Return type:
- isoformat()#
Express the date as ISO 8601 at its own precision.
- Returns:
YYYY,YYYY-MM, orYYYY-MM-DD.- Return type:
- classmethod parse(value)#
Read a date written as
YYYY,YYYY-MM, orYYYY-MM-DD.- Parameters:
value (
str) – The date, in one of the three ISO 8601 precisions.- Returns:
The date at the precision the text states.
- Return type:
- Raises:
ValueError – Raised if the text is not one of the three forms, or states a month or a day outside its range.
- to_date()#
Express the date as a
datetime.date, when it states a full one.