NAME

Pitonyak::DateUtil - Format and convert Time/Date strings


SYNOPSIS

use Pitonyak::DateUtil;


Formatting

A time is formatted based on a format string. The number of times that a special character exists indicates the number of digits that will be used. The format character 'YYYYMMDD.hhmmss' yields a four digit year, two digit month, two digit day, a period, two digit hour, etc... Characters that are not considered special are inserted verbatim. Characters that are escaped with a backslash '\' are also inserted verbatim. Use '\\' to insert a backslash.

The special format characters are as follows:

h = hour (0-24)
m = minute (0-59)
s = second (0-59)
Y = year
In Perl, the earliest year is 1900.

M = Month (1-12)
Perl uses (0-11)

W = Month (JANUARY, FEBRUARY, ..., DECEMBER)
I really should allow these to be in other languages as well.

y = year day (0-364)
D = month day (0-30)
w = week day (1=Sunday, ..., 7=Saturday)
Perl uses (0=Sunday, ... , 6=Saturday)


DESCRIPTION

Convert time and date information between different formats. This can convert between text representations and an integer.

time_date_str

time_date_str($format_string, [$time_integer])

Ignoring the time to make the call, both of the following calls are equivalent.

time_date_str($format_string); time_date_str($format_string, time());

This will return a formatted string with the specified time.

invert_time_date_str

invert_time_date_str($format_string, $formatted_time_date_string)

Convert a formatted time/date string to the same output as timelocal().

returns ($sec, $min, $hours, $mday, $mon, $year) where the $year will be -1 on error. December is mapped to 11 and the year 1900 is mapped to 0. One digit years are always mapped to 200y and two digit years are windowed so that 00-79 map to 20xx and 80-99 map to 19xx. Three digit years are obvious

time_date_str_to_int

time_date_str_to_int($format_string, $formatted_time_date_string)

Convert a formatted time/date string to an integer. -1 is returned on error.

change_time_date_str

change_time_date_str($desired_format, $current_format, $formatted_time_date_string)

Change a formatted time/date string to a different format.

This is nothing more than a shortcut to using time_date_str($desired_format, time_date_str_to_int($current_format, $formatted_time_date_string));


COPYRIGHT

Copyright 1998-2002, Andrew Pitonyak (perlboy@pitonyak.org)

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Modification History

March 13, 1998

Version 1.00 First release

September 10, 2002

Version 1.01 Changed internal documentation to POD documentation. Added parameter checking.