File Coverage

blib/lib/WWW/Mixi/OO/I18N/UTF8.pm
Criterion Covered Total %
statement 21 51 41.1
branch 0 8 0.0
condition n/a
subroutine 7 12 58.3
pod 4 4 100.0
total 32 75 42.6


line stmt bran cond sub pod time code
1             # -*- cperl -*-
2             # copyright (C) 2005 Topia . all rights reserved.
3             # This is free software; you can redistribute it and/or modify it
4             # under the same terms as Perl itself.
5             # $Id: UTF8.pm 88 2005-02-04 04:21:19Z topia $
6             # $URL: file:///usr/minetools/svnroot/mixi/trunk/WWW-Mixi-OO/lib/WWW/Mixi/OO/I18N/UTF8.pm $
7             package WWW::Mixi::OO::I18N::UTF8;
8 1     1   1189 use strict;
  1         2  
  1         31  
9 1     1   5 use warnings;
  1         2  
  1         22  
10 1     1   4 use Carp;
  1         2  
  1         49  
11 1     1   5 use POSIX;
  1         2  
  1         6  
12 1     1   2232 use base qw(WWW::Mixi::OO::I18N);
  1         2  
  1         117  
13 1     1   7 use Encode;
  1         2  
  1         85  
14 1     1   6 use utf8;
  1         2  
  1         10  
15              
16             sub convert_from_http_content {
17 0     0 1   my ($this, $charset, $str) = @_;
18              
19 0           decode($charset, $str);
20             }
21              
22             sub convert_to_http_content {
23 0     0 1   my ($this, $charset, $str) = @_;
24              
25 0           encode($charset, $str);
26             }
27              
28             sub convert_login_time {
29 0     0 1   my ($this, $timestr) = @_;
30 0 0         return undef unless defined $timestr;
31 0           my $time = 0;
32 0     0     my $add_time = sub { $time += $1; '' };
  0            
  0            
33 0           $timestr =~ s/(\d+)日/&$add_time/eg;$time *= 24;
  0            
  0            
34 0           $timestr =~ s/(\d+)時間/&$add_time/eg;$time *= 60;
  0            
  0            
35 0           $timestr =~ s/(\d+)分/&$add_time/eg;$time *= 60;
  0            
  0            
36 0           $timestr =~ s/^(\d+)$/&$add_time/eg;
  0            
37 0 0         if ($timestr) {
38 0           croak("Couldn't parse login timestr. junk: $timestr, parsed: $time");
39             }
40 0           $timestr = strftime('%Y/%m/%d %H:%M', localtime(time() - $time));
41 0 0         return wantarray ? ($timestr, $time) : $timestr;
42             }
43              
44             sub convert_time {
45 0     0 1   my ($this, $timestr) = @_;
46 0 0         return undef unless defined $timestr;
47 0           $timestr =~ s|(\d+)年(\d+)月(\d+)日|$1/$2/$3|g;
48 0           $timestr =~ s|(\d+)月(\d+)日|$1/$2|g;
49 0           return $timestr;
50             }
51              
52             1;