File: date.parse_time.t

package info (click to toggle)
libdate-manip-perl 6.98-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 14,928 kB
  • sloc: perl: 222,846; sh: 54; ansic: 26; makefile: 8
file content (109 lines) | stat: -rwxr-xr-x 1,855 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl

use warnings;
use strict;
use Test::Inter;
$::ti = new Test::Inter $0;
require "tests.pl";

our $obj = new Date::Manip::Date;
$obj->config("forcedate","2000-01-21-01:02:03, America/New_York");

sub test {
   my(@test)=@_;
   if ($test[0] eq "config") {
      shift(@test);
      $obj->config(@test);
      return ();
   }

   $obj->_init();
   my $err = $obj->parse_time(@test);
   if ($err) {
      return $obj->err();
   } else {
      my $d1 = $obj->value();
      return $d1;
   }
}

my $tests="

# Times

17:30:15 => 2000012117:30:15

'17:30:15 AM' => '[parse_time] Invalid time string'

'5:30:15 PM' => 2000012117:30:15

5:30:15 => 2000012105:30:15

17:30:15.25 => 2000012117:30:15

17:30:15,25 => 2000012117:30:15

'17:30:15.25 AM' => '[parse_time] Invalid time string'

'5:30:15.25 PM' => 2000012117:30:15

'5:30:15,25 PM' => 2000012117:30:15

5:30:15.25 => 2000012105:30:15

17:30.25 => 2000012117:30:15

'17:30.25 AM' => '[parse_time] Invalid time string'

'5:30.25 PM' => 2000012117:30:15

5:30.25 => 2000012105:30:15

17.5 => 2000012117:30:00

17,5 => 2000012117:30:00

'17.5 AM' => '[parse_time] Invalid time string'

'5.5 PM' => 2000012117:30:00

5.5 => 2000012105:30:00

17:30 => 2000012117:30:00

'17:30 AM' => '[parse_time] Invalid time string'

'5:30 PM' => 2000012117:30:00

5:30 => 2000012105:30:00

midnight => 2000012100:00:00

5:30 => 2000012105:30:00

5:30:02 => 2000012105:30:02

15:30:00 => 2000012115:30:00

5pm => 2000012117:00:00

123015 => 2000012112:30:15

'24:00' => 2000012100:00:00

";

$::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: