Class ValidatesTimeliness::Formats
In: lib/validates_timeliness/formats.rb
Parent: Object

A date and time parsing library which allows you to add custom formats using simple predefined tokens. This makes it much easier to catalogue and customize the formats rather than dealing directly with regular expressions.

Formats can be added or removed to customize the set of valid date or time string values.

Methods

Public Class methods

Adds new formats. Must specify format type and can specify a :before option to nominate which format the new formats should be inserted in front on to take higher precedence. Error is raised if format already exists or if :before format is not found.

Loop through format expressions for type and call proc on matches. Allow pre or post match strings to exist if strict is false. Otherwise wrap regexp in start and end anchors. Returns time array if matches a format, nil otherwise.

Delete formats of specified type. Error raised if format not found.

Removes formats where the 1 or 2 digit month comes first, to eliminate formats which are ambiguous with the European style of day then month. The mmm token is ignored as its not ambigous.

[Validate]