Sha256: 0b66844f3e83f74a807690136d3ad0a442271a90b3e10c4f5f3708bd15a699ec

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

h1. partial-date

* "Homepage":https://github.com/58bits/partial-date#readme
* "Issues":https://github.com/58bits/partial-date/issues
* "Documentation":http://rubydoc.info/gems/partial-date/frames

h2. Description

A simple date class that can be used to store partial date values in a single column/attribute. An example use case would include an archive, or catalogue entry where the complete date is unknown.

h2. Features

PartialDate::Date uses an 8 digit integer to store year, month and day values. Values for month and day are optional.
Use @date.value@ to set or persist the date to a persistance store. 

h2. Examples

bc.. require 'partial-date' 

# Default initializer 
date = PartialDate::Date.new
# => 
date.value
# => 0

# Initialize from a block of integers
date = PartialDate::Date.new {|d| d.year = 2012, d.month = 01}
# => 2012-01
date.value
# => 20120100

# Initialize from a block of strings
date = PartialDate::Date.new {|d| d.year = "2012", d.month = "01"}
# => 2012-01
date.value
# => 20120100

# Initialize from the class load method - for rehydrating a date instance from a stored integer date value.
date = PartialDate::Date.load 20121201
# => 2012-12-01
date.year
# => 2012
date.month
# => 12
date.day
# => 1

h2. Install

@$ gem install partial-date@

h2. TODO

# @PartialDate::Date.parse@ method for construction from strings.

h2. Copyright

Copyright (c) 2012 Anthony Bouch

See {file:LICENSE.txt} for details.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
partial-date-1.1.0 README.textile