class RDF::EDTF::Literal

An EDTF Date literal

@example Initializing an EDTF literal with {RDF::Literal}

RDF::Literal('107x', datatype: RDF::EDTF::Literal::DATATYPE)

Constants

BASETIME
CHOICELIST
CONSECUTIVES
DATATYPE
DATE
DATEANDTIME
DATEORSEASON
DATEWITHINTERNALUNCERTAINTY
DAY
DAYANDMONTHUNSPECIFIED
DAYUNSPECIFIED
DAYWITHU
DIGIT
DIGITORU
EARLIER
GRAMMAR

Grammar is articulated according to the BNF in the EDTF 1.0 pre-submission specification, except where noted above.

@todo investigate the allowance for out-of-range days (e.g. 2013-02-31) in

`INTERNALUNSPECIFIED`

@todo follow up on zone offset `00:00`; disallow, if appropriate, once

{https://github.com/inukshuk/edtf-ruby/issues/14} is closed

@todo disallow spaces in LISTCONTENT when

{https://github.com/inukshuk/edtf-ruby/issues/15} is closed

@see www.loc.gov/standards/datetime/pre-submission.html#bnf

HOUR
INCLUSIVELIST
INTERNALUNCERTAINORAPPROXIMATE
INTERNALUNSPECIFIED
IUABASE
L0INTERVAL
L1END
L1INTERVAL
L1START
L2INTERVAL
LATER
LEVEL0EXPRESSION
LEVEL1EXPRESSION
LEVEL2EXPRESSION
LISTCONTENT

list contents are specified here to allow spaces:

e.g. [1995, 1996, 1997]

this is not allowed in the specification's grammar see: github.com/inukshuk/edtf-ruby/issues/15

LISTELEMENT
LONGYEARSCIENTIFIC
LONGYEARSIMPLE
MASKEDPRECISION
MINUTE
MONTH
MONTHDAY
MONTHDAYWITHU
MONTHUNSPECIFIED
MONTHWITHU
NEGATIVEYEAR
ONETHRU12
ONETHRU13
ONETHRU23
ONETHRU29
ONETHRU3
ONETHRU30
ONETHRU31
ONETHRU59
POSITIVEDIGIT
POSITIVEDIGITORU
POSITIVEINTEGER
POSITIVEYEAR
QUALIFYINGSTRING
SEASON
SEASONNUMBER
SEASONQUALIFIED
SECOND
TIME
UASYMBOL
UNCERTAINORAPPROXDATE
UNSPECIFIED
YEAR
YEARMONTH
YEARMONTHDAY
YEARMONTHDAYWITHU
YEARMONTHWITHU

these allow days out of range for the month given (e.g. 2013-02-31) is this a bug in the EDTF BNF?

YEARWITHONEORTWOUNSPECIFEDDIGITS
YEARWITHU
YYEAR
ZEROTHRU23
ZEROTHRU59
ZONEOFFSET

Zone offset is specified loosely, due to the issue documented here:

https://github.com/inukshuk/edtf-ruby/issues/14

The correct specification is: ZONEOFFSET = %r(Z|((+|-))(#{ONETHRU13}((:#{MINUTE})|$)|14:00|00:#{ONETHRU59})).freeze

Public Class Methods

new(value, options = {}) click to toggle source

Initializes an RDF::Literal with EDTF datatype.

Casts lexical values with the correct datatype to EDTF, if they are parsable. Otherwise retains their original value as an `#invalid?` literal.

@see RDF::Literal

Calls superclass method
# File lib/rdf/edtf/literal.rb, line 153
def initialize(value, options = {})
  value = EDTF.parse(value) || value
  @string = value.edtf if value.respond_to? :edtf
  super
end