Boltx.Types.Duration (Boltx v0.0.2)
a Duration type, as introduced in bolt V2.
Composed of months, days, seconds and nanoseconds, it can be used in date operations
Summary
Functions
Create a Duration struct from data returned by Neo4j.
Convert a %Duration in a cypher-compliant string. To know everything about duration format, please see: https://neo4j.com/docs/cypher-manual/current/syntax/temporal/#cypher-temporal-durations
Types
@type t() :: %Boltx.Types.Duration{ days: non_neg_integer(), hours: non_neg_integer(), minutes: non_neg_integer(), months: non_neg_integer(), nanoseconds: non_neg_integer(), seconds: non_neg_integer(), weeks: non_neg_integer(), years: non_neg_integer() }
Functions
create(months, days, seconds, nanoseconds)
Create a Duration struct from data returned by Neo4j.
Neo4j returns a list of 4 integers:
- months
- days
- seconds
- nanoseconds
Struct elements are computed in a logical way, then for exmple 65 seconds is 1min and 5 seconds. Beware that you may not retrieve the same data you send! Note: days are not touched as they are not a fixed number of days for each month.
Example:
iex> Duration.create(15, 53, 125, 54)
%Boltx.Types.Duration{
days: 53,
hours: 0,
minutes: 2,
months: 3,
nanoseconds: 54,
seconds: 5,
weeks: 0,
years: 1
}
format_param(duration)
Convert a %Duration in a cypher-compliant string. To know everything about duration format, please see: https://neo4j.com/docs/cypher-manual/current/syntax/temporal/#cypher-temporal-durations