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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
|
#!/usr/bin/perl
use warnings;
use strict;
use Test::Inter;
$::ti = new Test::Inter $0;
require "tests.pl";
my $obj = new Date::Manip::Delta;
$obj->config("forcedate","now,America/New_York");
sub test {
my($delta,@test)=@_;
$obj->parse($delta);
return $obj->printf(@test);
}
my $tests="
1:2:3:4:5:6:7
'|A %% B|'
=>
'|A % B|'
1:2:3:4:5:6:7
'|Month: %Mv|'
=>
'|Month: 2|'
1:2:3:4:5:6:7
'|Day: %+05dv|'
=>
'|Day: +0004|'
1:2:3:4:5:6:7
'|Day: %+<5dv|'
=>
'|Day: +4|'
1:2:3:4:5:6:7
'|Day: %>5sv|'
=>
'|Day: 7 |'
1:2:3:4:5:6:7
'|%yv %Mv %wv %dv %hv %mv %sv|'
=>
'|1 2 3 4 5 6 7|'
1:2:3:4:5:6:7
'|%.4yyM %.4MMM %.4wws %.4dds %.4hhs %.4mms %.4sss|'
=>
'|1.1667 2.0000 3.6018 4.2126 5.1019 6.1167 7.0000|'
1:2:3:4:5:6:7
'|%.4Myw|'
=>
'|14.6900|'
1:2:3:4:5:6:7
'|%yyy %MyM %www %dwd %hwh %mwm %sws|'
=>
'|1 14 3 25 605 36306 2178367|'
1:2:3:4:5:6:7
'|%.4yyM %.4MyM %.4wws %.4dws %.4hws %.4mws %.4sws|'
=>
'|1.1667 14.0000 3.6018 25.2126 605.1019 36306.1167 2178367.0000|'
1:2:3:4:5:6:7
'|%>8.3yyM %>8.3MyM %>8.3wws %>8.3dws %>8.3hws %>8.3mws %>8.3sws|'
=>
'|1.167 14.000 3.602 25.213 605.102 36306.117 2178367.000|'
1:2:3:4:5:6:7
'|%<8.3yyM %<8.3MyM %<8.3wws %<8.3dws %<8.3hws %<8.3mws %<8.3sws|'
=>
'| 1.167 14.000 3.602 25.213 605.102 36306.117 2178367.000|'
1:2:3:4:5:6:7
'|%08.3yyM %08.3MyM %08.3wws %08.3dws %08.3hws %08.3mws %08.3sws|'
=>
'|0001.167 0014.000 0003.602 0025.213 0605.102 36306.117 2178367.000|'
1:2:3:4:5:6:7
'|%+<8.3yyM %+<8.3MyM %+<8.3wws %+<8.3dws %+<8.3hws %+<8.3mws %+<8.3sws|'
=>
'| +1.167 +14.000 +3.602 +25.213 +605.102 +36306.117 +2178367.000|'
1:2:3:4:5:6:7
'|%+08.3yyM %+08.3MyM %+08.3wws %+08.3dws %+08.3hws %+08.3mws %+08.3sws|'
=>
'|+001.167 +014.000 +003.602 +025.213 +605.102 +36306.117 +2178367.000|'
1:2:3:4:5:6:7
'|%.4yys %.4MMs %.4wws %.4dds %.4hhs %.4mms %.4sss|'
=>
'|1.2357 2.8284 3.6018 4.2126 5.1019 6.1167 7.0000|'
1:2:3:4:5:6:7
'|%.3yyy %.3MyM %.3wyw %.3dyd %.3hyh %.3mym %.3sys|'
=>
'|1.000 14.000 63.874 451.116 10831.790 649913.400 38994811.000|'
1:2:3:4:5:6:7
'|%.4yys %.4Mys %.4wys %.4dys %.4hys %.4mys %.4sys|'
=>
'|1.2357 14.8284 64.4755 451.3288 10831.8919 649913.5167 38994811.0000|'
'1:2:3:4:5:6:7 business'
'|%.4yys %.4Mys %.4wys %.4dys %.4hys %.4mys %.4sys|'
=>
'|1.2417 14.9000 64.7871 323.9356 2915.4207 174925.2417 10495514.5000|'
1:2:3:4:5:6:0
'|%Dt|'
=>
'|+1:2:+3:4:+5:6:0|'
'1:2:3:4:5:6:0 business'
'|%Dt|'
=>
'|+1:2:+3:+4:5:6:0|'
-1:2:3:4:5:6:0
'|%Dt|'
=>
'|-1:2:-3:4:-5:6:0|'
1:2:3:4:5:6:0
'|%+Dt|'
=>
'|+1:+2:+3:+4:+5:+6:+0|'
-1:2:3:4:5:6:0
'|%+Dt|'
=>
'|-1:-2:-3:-4:-5:-6:-0|'
1:2:3:4:5:6:0
'|%Dyy|'
=>
'|+1|'
1:2:3:4:5:6:0
'|%DyM|'
=>
'|+1:2|'
1:2:3:4:5:6:0
'|%Dyd|'
=>
'|+1:2:+3:4|'
'1:2:3:4:5:6:0 business'
'|%Dyy|'
=>
'|+1|'
'1:2:3:4:5:6:0 business'
'|%DyM|'
=>
'|+1:2|'
'1:2:3:4:5:6:0 business'
'|%Dyd|'
=>
'|+1:2:+3:+4|'
1:2:3:4:5:6:0
'|%+Dyd|'
=>
'|+1:+2:+3:+4|'
1:2:3:4:5:6:0
'|%+>10Dyd|'
=>
'|+1:+2:+3:+4|'
1:2:3:4:5:6:0
'|%+>18Dyd|'
=>
'|+1:+2:+3:+4 |'
1:2:3:4:5:6:0
'|%+18Dyd|'
=>
'| +1:+2:+3:+4|'
1:2:3:4:5:6:0
'|%+<18Dyd|'
=>
'| +1:+2:+3:+4|'
1:2:3:4:5:6:0 %DyM %Dyd %Dyy => +1:2 +1:2:+3:4 +1
0:0:0:0:-720:0:0
'|%Dt|'
=>
'|+0:0:+0:0:-720:0:0|'
'1:2:3:4:5:6:7'
'|%Ddm|'
=>
'|+4:+5:6|'
'1:2:3:4:5:6:7 business'
'|%Dhm|'
=>
'|+5:6|'
";
$::ti->tests(func => \&test,
tests => $tests);
$::ti->done_testing();
#Local Variables:
#mode: cperl
#indent-tabs-mode: nil
#cperl-indent-level: 3
#cperl-continued-statement-offset: 2
#cperl-continued-brace-offset: 0
#cperl-brace-offset: 0
#cperl-brace-imaginary-offset: 0
#cperl-label-offset: 0
#End:
|