Sha256: 583f12a576ed48ff02665caeaf952fc6d749ac8b55cad0e5903b8320ca3b5061

Contents?: true

Size: 1.86 KB

Versions: 3

Compression:

Stored size: 1.86 KB

Contents

h1. partial-date

* See the "ChangeLog":https://github.com/58bits/partial-date/blob/master/ChangeLog.textile for details of this release.

* "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 optional and can be a negative value. Month and day are optional, but month must be set before day.

h2. Features

PartialDate::Date uses a 30 bit 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

3 entries across 3 versions & 1 rubygems

Version Path
partial-date-1.1.7 README.textile
partial-date-1.1.6 README.textile
partial-date-1.1.5 README.textile