File: strftime.t

package info (click to toggle)
libtime-format-perl 1.11-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 248 kB
  • ctags: 34
  • sloc: perl: 522; makefile: 4
file content (36 lines) | stat: -rwxr-xr-x 979 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
#!/perl -I..

use strict;
use Test::More tests => 6;

BEGIN { $Time::Format::NOXS = 1 }
BEGIN { use_ok 'Time::Format', qw(%strftime) }
my $posix_bad;
BEGIN {
    $posix_bad = eval ('use POSIX (); 1')? 0 : 1;
    delete $INC{'POSIX.pm'};
    %POSIX:: = ();
}
my $tl_bad;
BEGIN
{
    $tl_bad = eval ('use Time::Local; 1')? 0 : 1
}

SKIP:
{
    skip 'POSIX is not available', 5       if $posix_bad;
    skip 'Time::Local is not available', 5 if $tl_bad;

    my $t = timelocal(9, 58, 13, 5, 5, 103);    # June 5, 2003 at 1:58:09 pm
    $t .= '.987654321';

    # Be sure to use ONLY ansi standard strftime codes here,
    # otherwise the tests will fail on somebody's system somewhere.

    is $strftime{'%d',$t},      '05'        => 'day of month';
    is $strftime{'%m',$t},      '06'        => 'Month number';
    is $strftime{'%M',$t},      '58'        => 'minute';
    is $strftime{'%H',$t},      '13'        => 'hour';
    is $strftime{'%Y',$t},      '2003'      => 'year';
}