2006/04/28

手動轉OpenWebMail的address.book成vCard

搞不清楚什麼是 X-OWM-UID
http://www.acatysmoof.com/posting/openwebmail-patches/041025/vCard_data_structure/

然後用下列的perl script就轉成!
-----------------------------

open(F,'./address.book');
while() {
chomp;
my($name, $email) = split('@@@',$_);
my $xuid = make_x_owm_uid();
print qq~
BEGIN:VCARD
VERSION:3.0
N:;$name;;;
FN:$name
EMAIL:$email
TZ:08:00
CLASS:PUBLIC
REV:2006-04-28T09:13:50Z
X-OWM-CHARSET:big5
X-OWM-UID:$xuid
END:VCARD
~
;
}
close(F);

sub make_x_owm_uid {
my ($uid_sec,$uid_min,$uid_hour,$uid_mday,$uid_mon,$uid_year) = gmtime(time);
my @chars = ( 'A' .. 'Z', 0 .. 9 );
my $longrandomstring = join '', map { $chars[rand @chars] } 1..12;
my $shortrandomstring = join '', map { $chars[rand @chars] } 1..4;
my $uid = ($uid_year+1900).sprintf("%02d",($uid_mon+1)).sprintf("%02d",$uid_mday)."-".
sprintf("%02d",$uid_hour).sprintf("%02d",$uid_min).sprintf("%02d",$uid_sec)."-".
$longrandomstring."-".$shortrandomstring;
return $uid;
}

0 Comments:

Post a Comment

<< Home