Database Reference
In-Depth Information
$hour = "00" ; # 12:xx:xx AM times are 00:xx:xx
}
elsif ( $hour < 12 && defined ( $4 ) && uc ( $4 ) eq "PM" )
{
$hour += 12 ; # PM times other than 12:xx:xx
}
$val = "$hour:$min:$sec" ;
}
The time parts are placed into $1 , $2 , and $3 , with $3 set to undef if the seconds part is
missing. The suffix goes into $4 if it's present. If the suffix is AM or missing ( undef ), the
value is interpreted as an AM time. If the suffix is PM , the value is interpreted as a PM
time.
See Also
This section is just the beginning of what you can do when processing dates for data-
transfer purposes. Date and time testing and conversion can be highly idiosyncratic,
and the sheer number of issues to consider is mind-boggling:
• What is the basic date format? Dates come in several common styles, such as ISO
( CCYY-MM-DD ), US ( MM-DD-YY ), and British ( DD-MM-YY ) formats. And these are just
some of the more standard formats. Many more are possible. For example, a datafile
may contain dates written as June 17, 1959 or as 17 Jun '59 .
• Are trailing times permitted on dates, or perhaps required? When times are ex‐
pected, is the full time required or just the hour and minute?
• Do you permit special values like now or today ?
• Are date parts required to be delimited by a particular character, such as - or / , or
are other delimiters permitted?
• Are date parts required to have a specific number of digits? Or are leading zeros on
month and year values permitted to be missing?
• Are months written numerically, or represented as month names like January or
Jan ?
• Are two-digit year values permitted? Should they be converted to have four digits?
If so, what is the transition point within the range 00 to 99 at which values change
from one century to another?
• Should date parts be checked to ensure their validity? Patterns can recognize strings
that look like dates or times, but while they're extremely useful for detecting mal‐
formed values, they may not be sufficient. A value like 1947-15-99 may match a
pattern but isn't a legal date. Pattern testing is thus most useful in conjunction with
range checks on the individual parts of the date.
Search WWH ::




Custom Search