Giter VIP home page Giter VIP logo

edtf-ruby's Introduction

EDTF-Ruby

Ruby implementation of the Extended Date/Time Format Specification.

Compatibility

As of EDTF Specification DRAFT, August 4, 2001:

  • Level 0: fully implemented
  • Level 1: fully implemented
  • Level 2: implemented features 202, 203, 204, 2041, 207, 208, and 209

The level 2 list extensions (203 and 204) currently return simple Ruby arrays; therefore, advanced behavior (such as 'earlier' or 'later') is parsed correctly but not yet exposed by the Ruby API.

The level 2 extensions 201 and 205 are currently not supported.

EDTF-Ruby has been confirmed to work on the following Ruby implementations: 1.9.2, 1.8.7, rbx, jruby.

Quickstart

EDTF Ruby is implemented as an extension to the regular Ruby date/time classes. You can access parse EDTF strings either using Date.edtf or EDTF.parse; if given a valid EDTF string the return value will either be an (extended) Date, EDTF::Interval or Range (for masked precision strings) instance.

$ [sudo] gem install edtf
$ irb
> require 'edtf'
> d = Date.edtf('1984?')
> d.uncertain?
 => true
> d.certain!
> d.uncertain?               
 => false
> d = Date.edtf('1999-03-uu')
> d.unspecified?
 => true
> d.unspecified? :year
 => false
> d.unspecified? :day
 => true
> Date.edtf('2003-24').winter?
 => true
> Date.edtf('196x')
 => #<Date: 1960-01-01>...#<Date: 1970-01-01>
> Date.edtf('y-17e7').year
 => -170000000
> d = Date.edtf('1984-06?/2004-08?')
> d.from.uncertain?
 => true
> d.each.to_a.length
 => 7367 # days between 1984-06 and 2004-08
> Date.edtf('2004-01-01/open').open?
 => true

For additional features take a look at the rdoc, source, and rspec examples.

Development

$ git clone https://[email protected]/inukshuk/edtf-ruby.git
$ cd edtf-ruby
$ bundle install
$ bundle exec rake racc
$ bundle exec rspec spec
$ bundle exec cucumber

For extra credit, fork the project on github: pull requests welcome!

Credits

EDTF-Ruby was written by Sylvester Keil.

Published under the terms and conditions of the FreeBSD License; see LICENSE for details.

edtf-ruby's People

Contributors

inukshuk avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.