Lingua::KO::DateTime - convert time to korean format.


Lingua-KO-DateTime documentation Contained in the Lingua-KO-DateTime distribution.

Index


Code Index:

NAME

Top

Lingua::KO::DateTime - convert time to korean format.

SYNOPSIS

Top

DESCRIPTION

Top

This module can convert asctime to korean format. you can select euc-kr charset. asctime is ASC C standard format will from localtime like this:

        $asctime = localtime();

METHOD

Top

new

        my $kdt = new Lingua::KO::DateTime(charset=>'euc-kr');

Instantiates a new object.

set_env

        my $kdt->set_env(charset=>'euc-kr');

set charset encode.

* charset -> euc-kr only now.

convert

        $kdt->convert(asctime=>'Thu Oct 13 04:54:34 1994',output=>'date');

* asctime -> input asctime data.
* output -> output in 3 types: date,time,datetime.

AUTHORS

Top

Lingua::KO::DateTime by C.H. Kang

COPYRIGHT

Top

WARRANTY

Top

The Lingua::KO::DateTime is free Open Source software.

IT COMES WITHOUT WARRANTY OF ANY KIND.


Lingua-KO-DateTime documentation Contained in the Lingua-KO-DateTime distribution.

package Lingua::KO::DateTime;

use strict;
use warnings;

our $VERSION='0.02';

my $charset;

my $dt_string = {
                'euc-kr' =>     {
                        'year'   => '³â',
                        'month'  => '¿ù',
                        'day'    => 'ÀÏ',
                        'hour'   => '½Ã',
                        'minute' => 'ºÐ',
                        'second' => 'ÃÊ',
                },
}; 
my $lc_string = {
                'month'=>       {
                    'jan'       =>      '1',    'feb'   =>      '2',    'mar'   =>      '3',
                    'apr'       =>      '4',    'may'   =>      '5',    'jun'   =>      '6',
                    'Jul'       =>      '7',    'aug'   =>      '8',    'sep'   =>      '9',
                    'sept'      =>      '9',    'oct'   =>      '10',   'nov'   =>      '11',
                    'dec'       =>      '12'
                },
                'day' => {
                    '1'         =>      '1',    '2'     =>      '2',    '3'     =>      '3',
                    '4'         =>      '4',    '5'     =>      '5',    '6'     =>      '6',
                    '7'         =>      '7',    '8'     =>      '8',    '9'     =>      '9',
                    '10'        =>      '10',   '11'    =>      '11',   '12'    =>      '12',
                    '13'        =>      '13',   '14'    =>      '14',   '15'    =>      '15',
                    '16'        =>      '16',   '17'    =>      '17',   '18'    =>      '18',
                    '19'        =>      '19',   '20'    =>      '20',   '21'    =>      '21',
                    '22'        =>      '22',   '23'    =>      '23',   '24'    =>      '24',
                    '25'        =>      '25',   '26'    =>      '26',   '27'    =>      '27',
                    '28'        =>      '28',   '29'    =>      '29',   '30'    =>      '30',
                    '31'        =>      '31'            
                },
                'hour' => {
                    '1'         =>      '1',    '2'     =>      '2',    '3'     =>      '3',
                    '4'         =>      '4',    '5'     =>      '5',    '6'     =>      '6',
                    '7'         =>      '7',    '8'     =>      '8',    '9'     =>      '9',
                    '10'        =>      '10',   '11'    =>      '11',   '12'    =>      '12',
                    '13'        =>      '13',   '14'    =>      '14',   '15'    =>      '15',
                    '16'        =>      '16',   '17'    =>      '17',   '18'    =>      '18',
                    '19'        =>      '19',   '20'    =>      '20',   '21'    =>      '21',
                    '22'        =>      '22',   '23'    =>      '23',   '24'    =>      '24'    
                }, 
};


sub new {
    my ($class,%args) = @_;
    my $self = {};
    $charset = $args{'charset'} if ($args{'charset'});

    bless $self, $class;
    return $self;
}




sub set_env {
    my ( $self, %args ) = @_;
    $charset = $args{'charset'} if ($args{'charset'}) ;

    return(1);
}

sub convert {
    my ( $self, %args ) = @_;
    my ($week,$year,$mon,$day,$hour,$min,$sec,$date,$time);

    if (!$args{'asctime'}) {
        $args{'asctime'} = localtime();
    }

    ($week,$mon,$day,$time,$year) = split(/\s+/,$args{'asctime'});
    ($hour,$min,$sec) = split(/:/,$time);
    $mon = lc($mon);

    $args{'output'} = "datetime" if(!$args{'output'});
    $charset = "euc-kr" if(!$charset);


    $date = $year . $dt_string->{$charset}{"year"} . " " .
            $lc_string->{'month'}{$mon} . $dt_string->{$charset}{"month"} . " " .
            $lc_string->{'day'}{$day} . $dt_string->{$charset}{"day"};

    $time = $hour . $dt_string->{$charset}{"hour"} . " " .
            $min . $dt_string->{$charset}{"minute"} . " " .
            $sec . $dt_string->{$charset}{"second"};


    return $date if($args{'output'} eq 'date');
    return $time if($args{'output'} eq 'time');
    return "$date $time" if($args{'output'} eq 'datetime');
}


1;