5. py2neo.ext.calendar
– Calendar¶
Maintained by: Nigel Small <nigel@py2neo.org>
The calendar module provides standardised date management functionality based on a calendar subgraph:
from py2neo import Graph, Node, Relationship
from py2neo.ext.calendar import GregorianCalendar
graph = Graph()
calendar = GregorianCalendar(graph)
alice = Node("Person", name="Alice")
birth = Relationship(alice, "BORN", calendar.date(1800, 1, 1).day)
death = Relationship(alice, "DIED", calendar.date(1900, 12, 31).day)
graph.create(alice, birth, death)
All dates managed by the GregorianCalendar
class
adhere to a hierarchy such as:
(calendar)-[:YEAR]->(2000)-[:MONTH]->(12)-[:DAY]->(25)
-
class
py2neo.ext.calendar.
GregorianCalendar
[source]¶ A Gregorian calendar stored in a graph as a tree of
(year)->(month)->(day)
.-
date
(year, month=1, day=1)[source]¶ Pick a date from this calendar.
Return type: GregorianDate
-
graph
= None¶ The graph associated with this calendar.
-
-
class
py2neo.ext.calendar.
GregorianDate
(calendar, year, month=1, day=1)[source]¶ A date picked from a
GregorianCalendar
.-
calendar
= None¶ The calendar from which this date was picked.
-
day
¶ The day node for this date.
Return type: py2neo.Node
-
graph
= None¶ The graph associated with this date.
-
month
¶ The month node for this date.
Return type: py2neo.Node
-
path
= None¶ Full
Path
representing this date.
-
year
¶ The year node for this date.
Return type: py2neo.Node
-