NAME

Date::Transform - Transform the format of dates.

SYNOPSIS

  use Date::Transform;
  
  my $dt = new Date::Transform( 
		i<input_format>,
		i<output_format>
  )

  i<$output_string_1>  = $dt->transform(i<input_string_1>);
  i<$output_string_2>  = $dt->transform(i<input_string_2>);
  i<$output_string_3>  = $dt->transform(i<input_string_3>);

  ...

  

DESCRIPTION

Sullivan Beck's excelllent Date::Manip it a superlative module for performing a vast number of operations involving dates. However, because of its extraordinary flexibility it is slow in operations where much date parsing is needed.

I found that more than 95% of my operations using dates required a simple transfor mation from one format to another, i.e. going from YYYY-mm-dd to mm/dd/YYYY. While Date::Manip's UnixDate function can do this, its flexibility means slower operations. The algorithm can be greatly accelerated when the input date has a specific format. Date::Transform does this. When the input format is known, Date::Transform creates a customized routine maximized for the specific transformation.

While a considerable initialization is required to derive the transformations, the transformations themselves see a 300-500% performance increase over Date::Manip.

Formats supported: %[aAbBcdHIjmMpSUwWxXyYZ] -- see POSIX::strftime()

METHODS

new( i<input_format>, i<output_format> )

Create a new Date::Manip::Transform object.
input_format is treated as a Regular Expression.

transform( i<date> )

Transforms the supplied date according to the transformation rules of the 
Date::Transform object.

a	weekday abbreviation                          Sun to Sat
A	Day of the Week                                  Monday
b	Month abbreviation                              Jan to Dec
B	Month of the Year                                January ... December
c	Compound time format                        e.g. Fri Apr 28 17:23:15 1995
d	Day of the Month,                                e.g. 15
H	Hour of the day                                    00-23
I		Hour of the day 								   01 to 12
j		Day of the year                                    0-365
m   month of year		                               01 to 12
M	Minute                                          	   00 to 59
p	AM or PM	                                           AM or PM
S	Second							                       00 to 59
U	Week of year, Sunday as first day	       01 to 53
w	Day of week                                        1 (Monday) to 7 (Sunday)
W	week of year, Monday as first day	       01 to 53
x	Compound format							   e.g. 04/28/95
X	Time	                                                   e.g. 03:30:01 AM
Y	Year	                                                   e.g. 2002
Z	Time Zone	                                       e.g. Pacific Daylight Time

NOTES

I would be happy to have this incorporated directly into Sullivan Beck's Date::Manip module.

Object Model

transform
+ source
+ filter
+ destination

HOW TO EXPAND

EXPORT

None by default.

TODO

Speed transformation where a rearrangement of numbers is the only thing necessary
Implement a default using user parameters or localtime()
Multiple language support.
Incoporate %l format.

AUTHOR

Christopher Brown, <chris.brown@cal.berkeley.edu>

SEE ALSO

perl, Date::Manip, Switch, Posix::strftime

COPYRIGHT

Copyright Christopher T. Brown 2003.