File: date_utf8.t

package info (click to toggle)
libtemplate-perl 3.102-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,680 kB
  • sloc: perl: 14,945; makefile: 11; sh: 5
file content (54 lines) | stat: -rw-r--r-- 1,367 bytes parent folder | download
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
#============================================================= -*-perl-*-
#
# t/date_utf8.t
#
# Tests the 'Date' plugin.
#
# Written by Andy Wardley <abw@wardley.org>
#
# Copyright (C) 2000 Andy Wardley. All Rights Reserved.
#
# This is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
# $Id$
#
#========================================================================

use utf8;
use strict;
use warnings;

use lib qw( ./lib ../lib );

use Template;
use Template::Test;
use Template::Plugin::Date;

use POSIX qw{ setlocale LC_ALL };
use Config;

# this test fails on CI workflow probably due to missing locale
skip_all( "Need to set env variable AUTHOR_TESTING=1" ) unless $ENV{AUTHOR_TESTING} && !$ENV{AUTOMATED_TESTING};

skip_all( "d_setlocale unset" ) unless $Config::Config{d_setlocale};

#$Template::Test::DEBUG = 0;

my $russian_locale = 'ru_RU.UTF-8';

my $loc = setlocale( LC_ALL, $russian_locale );
skip_all("no russian locale $russian_locale available") unless $loc && $loc eq $russian_locale;

setlocale( LC_ALL, 'C' );

my $params = {};
test_expect(\*DATA, { POST_CHOMP => 1 }, $params);

__DATA__
-- test --
[% USE russian = date(format => '%A, %e %B %Y', locale => 'ru_RU.UTF-8') %]
In Russian with UTF8: [% russian.format(1245) +%]

-- expect --
In Russian with UTF8: среда, 31 декабря 1969