On Aug 15, 2011, at 6:01 PM, Bruce D'Arcus wrote:

> On Mon, Aug 15, 2011 at 11:48 AM, Sylvester Keil <[email protected]> wrote:
>> I've updated the edtf Ruby gem to reflect the latest draft. The parser is 
>> based on the BNF with minimal changes to resolve a few conflicts and it 
>> works for all extensions except 201 and 205. The multiple dates (203, 204) 
>> right now return a simple array, which is to say that whilst features such 
>> as earlier/later are parsed correctly, that information is not exposed by 
>> the API. Eventually, we will need a new class to wrap these sets of dates.
>> 
>> A few minor issues will have to be resolved (e.g., how to deal with 
>> open/unknown intervals or how to sort intervals and seasons), but overall 
>> you should be able to experiment with the format if you are so inclined. 
>> Simply, gem install and require 'edtf'; you then parse EDTF with the 
>> Date.edtf class method.
> 
> Is the following correct according to the spec (note end "to" date for
> the interval)?
> 
> irb(main):014:0> d = Date.edtf('1984/1985')
> => #<EDTF::Interval:0x45932c @from=#<Date: 1984-01-01
> (4891401/2,0,2299161)>, @to=#<Date: 1985-01-01 (4892133/2,0,2299161)>>
> irb(main):015:0> d.from.to_s
> => "1984-01-01"
> irb(main):016:0> d.to.to_s
> => "1985-01-01"

It just occurred to me that I may have misunderstood your question slightly. I 
implemented Interval so as to stay very close to regular Ranges in order to 
support checks such as whether or not a given date falls into the interval. For 
that reason, we need the 'from' and 'to'; however, the Interval class will 
remember that the start and end date were specified using 'year precision'; 
this is important if we want to generate an EDTF string from the Interval and 
may be important for other checks. So, in other words, the from/to are not 
intended to be a direct mapping of the EDTF string, rather the Interval object 
is the mapping and will eventually need to expose a better API to all the 
features provided by EDTF intervals.

Sylvester


------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
xbiblio-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbiblio-devel

Reply via email to