Sha256: 2a60a9372c75d8921042fb8b80e40657ec4de3c166f575bf9e493497b994be63

Contents?: true

Size: 1.68 KB

Versions: 1

Compression:

Stored size: 1.68 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. Year is mandatory, but month and day are optional.

h2. Features

PartialDate::Date uses a 23bit register as the backing store for date instances, and bit fiddling to get or set year, month and day values. As such it will perform well in a loop or collection of date objects.

Use @date.value@ to get or set an Integer value that can be used to rehydrate a date object, or save the date value to a persistance store in a readable Integer form e.g. 20121201 for 2012 December 01. 

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.1 README.textile