The calendar module provides standardised date management functionality based on a calendar subgraph:
from py2neo import neo4j
from py2neo.calendar import GregorianCalendar
graph_db = neo4j.GraphDatabaseService()
time_index = graph_db.get_or_create_index(neo4j.Node, "TIME")
calendar = GregorianCalendar(time_index)
graph_db.create(
{"name": "Alice"},
(0, "BORN", calendar.day(1800, 1, 1)),
(0, "DIED", calendar.day(1900, 12, 31)),
)
The root calendar node is held within a dedicated node index which needs to be supplied to the calendar constructor.
All dates managed by the GregorianCalendar class adhere to a hierarchy such as:
(CALENDAR)-[:YEAR]->(2000)-[:MONTH]->(12)-[:DAY]->(25)
Bases: object
Fetch the calendar node representing the date range defined by start_date and end_date. If either are unspecified, this defines an open-ended range. Either start_date or end_date must be specified.
Fetch the calendar node representing the day specified by year, month and day.