Add RDF.DateTime.now/0

This commit is contained in:
Marcel Otto 2018-09-08 21:50:42 +02:00
parent 93b932620c
commit f4b9b0f434
2 changed files with 5 additions and 0 deletions

View file

@ -18,6 +18,7 @@ This project adheres to [Semantic Versioning](http://semver.org/) and
all numeric literals, eg. arithmetic functions all numeric literals, eg. arithmetic functions
- the logical operators and the Effective Boolean Value (EBV) coercion algorithm - the logical operators and the Effective Boolean Value (EBV) coercion algorithm
from the XPath and SPARQL specs on `RDF.Boolean` from the XPath and SPARQL specs on `RDF.Boolean`
- `RDF.DateTime.now/0`
- `RDF.Term.equal?/2` and `RDF.Term.equal_value?/2` - `RDF.Term.equal?/2` and `RDF.Term.equal_value?/2`
- `RDF.LangString.match_language?/2` - `RDF.LangString.match_language?/2`
- possibility to configure an application-specific default base IRI; for now it - possibility to configure an application-specific default base IRI; for now it

View file

@ -6,6 +6,10 @@ defmodule RDF.DateTime do
use RDF.Datatype, id: RDF.Datatype.NS.XSD.dateTime use RDF.Datatype, id: RDF.Datatype.NS.XSD.dateTime
def now() do
new(DateTime.utc_now())
end
# Special case for date and dateTime, for which 0 is not a valid year # Special case for date and dateTime, for which 0 is not a valid year
def convert(%DateTime{year: 0} = value, opts), do: super(value, opts) def convert(%DateTime{year: 0} = value, opts), do: super(value, opts)
def convert(%DateTime{} = value, _), do: value def convert(%DateTime{} = value, _), do: value