[go: up one dir, main page]

File: Time.pm

package info (click to toggle)
cstocs 1%3A3.42-2
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 260 kB
  • ctags: 33
  • sloc: perl: 725; makefile: 36
file content (102 lines) | stat: -rw-r--r-- 2,073 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
=head1 NAME

Cz::Time - Routines for printing dates in Czech

=head1 SYNOPSIS

	use Cz::Time;
	my $today = cz_wday() . " " . cz_date();
	my $new_year = " 1. " . cz_month_base(1); 

=head1 DESCRIPTION

Implements czech names of months and weekdays. The following functions
are exported:

=over 4

=item cz_date

Converts time (localtime if not specified) into Czech string, eg.
15. ledna 1997.

=item cz_month_base, cz_month

Czech names of months (1..12)

=item cz_wday, cz_ab_wday

Czech names of weekdays and weekdays' abreviation.

=back

By default they are returned in ISO-8859-2.

=head1 AUTHORS

(c) 1997 Jan Pazdziora <adelton@fi.muni.cz>,
    1997 Michael Mrka <michael@fi.muni.cz>

at Faculty of Informatics, Masaryk University, Brno

=head1 VERSION

0.02

=head1 SEE ALSO

perl(1), Cz::Cstocs(3).

=cut

package Cz::Time;

use strict;
use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK );

use Exporter;

@ISA = qw(Exporter);
@EXPORT = qw( cz_date cz_month cz_wday cz_month_base cz_ab_wday );
@EXPORT_OK = qw( cz_date cz_month cz_wday cz_month_base cz_ab_wday );
	
$VERSION = '0.02';

my @CZ_MONTH_BASE = qw( leden nor bezen duben kvten erven ervenec
        srpen z jen listopad prosinec );
my @CZ_WEEK_DAYS = qw( nedle pondl ter steda tvrtek ptek sobota );
my @CZ_AB_WEEK_DAYS = qw( Ne Po t St t P So );

sub cz_month_base
        {
        my $month = shift;
        return $CZ_MONTH_BASE[$month-1];
        }
sub cz_month
        {
        my $month = shift;
        local $_ = $CZ_MONTH_BASE[$month-1];
        s!en$!na! or s!ec$!ce! or s!ad$!adu! or s!or$!ora!;
        $_;
        }
sub cz_date
        {
        my @t;
        if (@_) { @t = @_; } else { @t = localtime; }
        return $t[3] . '. ' . cz_month($t[4] + 1) . ' ' . ($t[5] + 1900);
        }
sub cz_wday
        {
        my @t;
        if (@_) { @t = @_; } else { @t = localtime; }
        $CZ_WEEK_DAYS[$t[6]];
        }
sub cz_ab_wday
        {
        my @t;
        if (@_) { @t = @_; } else { @t = localtime; }
        $CZ_AB_WEEK_DAYS[$t[6]];
        }

1;
__END__