robertzk/syberiaMungebits — pull request #18 by peterhurford (2014-10-01 19:12:29+00:00)
Title: Timekeeper Mungebit

Take input in a wide variety of date/time formats and output it in a variety of consistent formats.

Supports many types of input:
* Three different separators: YYYY/MM/DD, YYYY-MM-DD, YYYY MM DD.
* Different order: MM/DD/YYYY (but not DD/MM/YYYY -- see assumptions, below).
* Spelt out months, in different orders: "January 1, 1970", "1 Jan 1970", "1970 Jan 01"
* Two-digit years (see assumptions below): "January 1, '70", "12/11/91"
* Jumbled input: "19911211", "1991dec11", "dec111991"
* Number of days since Jan 1 1970 (e.g., 306 -> 1970-11-03)

Supports five modes for output:
* mode = `date` (default) returns an R date (e.g., 1970-01-01)
* mode = `numeric` returns number of days since Jan 1, 1970
* mode = `holiday` returns `TRUE` or `FALSE` depending on if the date is on a US Federal Holiday
* mode = `weekend` returns `TRUE` or `FALSE` depending on if the date is on a weekend
* mode = `businessday` returns `TRUE` or `FALSE` depending on if the date is on a business day

Makes six assumptions about dates:
* 12/11/1991 will be December 11, 1991 (US dates)
* two-digit years > 20 refer to 20th century ('91 refers to 1991)
* two-digit years <= 20 refer to 21st century ('14 refers to 2014)
* two-digit years will be at end (12/11/20 will refer to December 11, 1920)
* numeric strings are dates if length 8, days since 1970 otherwise
* numeric strings as dates will be YYYYMMDD

More possible features (not done because YAGNI):
* Be smart enough to assume 91-12-11 is in YY-MM-DD, to assume 12-31-91 is in MM-DD-YY, and to assume 31-12-91 is in DD-MM-YY.
* Be able to pass in a string to override the six assumptions (i.e., get "12-11-1991" to default to Nov 12, 1991 (UK style) with `override="uk"`).