diff options
| author | fukachan <fukachan> | 2005-08-06 07:14:01 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2005-08-06 07:14:01 +0000 |
| commit | 300ff9fca415262c04473552abe16e968ca3fd10 (patch) | |
| tree | 96956d2bca5a455537d19af0b5d78813074ada7e /fml/lib/Mail/Message | |
| parent | bea3478a0296db866883b43006a76f2e8fd989ef (diff) | |
| download | fml8-300ff9fca415262c04473552abe16e968ca3fd10.tar.gz fml8-300ff9fca415262c04473552abe16e968ca3fd10.tar.bz2 fml8-300ff9fca415262c04473552abe16e968ca3fd10.zip | |
define get_time_from_header() method (moved from Mail::Message::DB).
Diffstat (limited to 'fml/lib/Mail/Message')
| -rw-r--r-- | fml/lib/Mail/Message/Utils.pm | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/fml/lib/Mail/Message/Utils.pm b/fml/lib/Mail/Message/Utils.pm index 202e539c..647210bd 100644 --- a/fml/lib/Mail/Message/Utils.pm +++ b/fml/lib/Mail/Message/Utils.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Utils.pm,v 1.10 2004/01/24 09:04:00 fukachan Exp $ +# $FML: Utils.pm,v 1.11 2004/07/23 13:16:45 fukachan Exp $ # package Mail::Message::Utils; @@ -89,6 +89,41 @@ sub from_to_name } + +=head2 get_time_from_header + +return formated time of message Date:. + +=cut + + +# Descriptions: return formated time of message Date: +# Arguments: OBJ($hdr) STR($type) +# Side Effects: none +# Return Value: STR +sub get_time_from_header +{ + my ($hdr, $type) = @_; + + if (defined($hdr) && $hdr->get('date')) { + use Time::ParseDate; + my $unixtime = parsedate( $hdr->get('date') ); + my ($sec,$min,$hour,$mday,$mon,$year,$wday) = localtime( $unixtime ); + + if ($type eq 'yyyymm') { + return sprintf("%04d%02d", 1900 + $year, $mon + 1); + } + elsif ($type eq 'yyyy/mm') { + return sprintf("%04d/%02d", 1900 + $year, $mon + 1); + } + } + else { + warn("cannot pick up Date: field"); + return ''; + } +} + + =head2 search_program($file [, $path_list ]) search C<$file>. |
