From 300ff9fca415262c04473552abe16e968ca3fd10 Mon Sep 17 00:00:00 2001 From: fukachan Date: Sat, 6 Aug 2005 07:14:01 +0000 Subject: define get_time_from_header() method (moved from Mail::Message::DB). --- fml/lib/Mail/Message/Utils.pm | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) 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>. -- cgit v1.2.1