Date.pm
NAME
Communiware::Date - date format handling routines for Communiware
SYNOPSIS
$date = $Communiware::Date::parse_date($date_string, $format); $date_string = $Communiware::Date::format_date($date, $format); $user_readable_format = $Communiware::Date::show_format($format);
DESCRIPTION
This module provides ways to convert user-defined date formats to standard Communiware format YYYY.MM.DD HH.MM.SS.
It uses subset of formats allowed for strftime function.
Any format, acceptable by strftime is acceptable by format_date, but only formats which do not contain textual names of month and weekday are acceptable for parse_date.
In addition, there is Communiware::Date::handler function, which preprocess results of form submission and converts all user-formated provided by Input date dynamic element to the standard representation
FUNCTIONS
parse_date
Convert date in specified format into standard Communiware YYYY.MM.DD HH.MM.SS representation.
SYNOPSYS
parse_date ($date,$format)
DESCRIPTION
Date is date string in user format. $format is format specification, as described in L<strftime>. Note that format specifiers which produce symbolic month names are not supported, as well as weekdays, julian dates and other exotic things.
Only supported specifiers are %m %d %y %Y %H %M %S
format_date
Formats date attribute using strftime. Arguments: date in YYYY.MM.DD HH:MM format, strftime format string, accuracy value. Accuracy value can be SECOND (default), HOUR, DAY, MONTH. YEAR or UNKNOWN. For values from HOUR from YEAR all format specifications for time interval less than given, removed from format. For UNKNOWN, three question marks are returned instead of date
In this fucntion defined constant array allowedn_date_formats which is used to transform date formats if date accuracy is spedified (strftime(3)). Indices of this array are allowed date accuracy values and values are strings composed from striftime format specifiers. Keys are possible values of date accuracy, values are strings of format specificators which are not allowed in strftime with this date accuracy.
fix_date ($date)
Appends $date to satisfy standard Communiware format ``YYYY.MM.DD HH.MI.SS''. A month and a day take value of 1 if absent. An hour, minutes and seconds take value of 0 if absent.
If an year is of two digits only, 2000 will be added if an year is less then 70, 1900 will be added otherwise.
If $date is an empty string fix_date returns an empty string too.
This function does NOT check date's validity, i.e. are minutes and seconds no greater then 60 and so on.
show_format
Syntax
show_format (format_string)
prints user_viewable representation of data format
sysdate
Returns current date in standard communiware format
This is equivalent to value returned by 'select fdate(sysdate)
from dual' but
whithout request to sql-server.
makedate
Fixes incorrect dates. Returns standard array with date elements (see localtime).