View | Details | Raw Unified | Return to bug 15769
Collapse All | Expand All

(-)a/C4/Koha.pm (-18 lines)
Lines 39-45 BEGIN { Link Here
39
	require Exporter;
39
	require Exporter;
40
	@ISA    = qw(Exporter);
40
	@ISA    = qw(Exporter);
41
	@EXPORT = qw(
41
	@EXPORT = qw(
42
		&slashifyDate
43
		&subfield_is_koha_internal_p
42
		&subfield_is_koha_internal_p
44
		&GetPrinters &GetPrinter
43
		&GetPrinters &GetPrinter
45
		&GetItemTypes &getitemtypeinfo
44
		&GetItemTypes &getitemtypeinfo
Lines 99-121 Koha.pm provides many functions for Koha scripts. Link Here
99
98
100
=cut
99
=cut
101
100
102
=head2 slashifyDate
103
104
  $slash_date = &slashifyDate($dash_date);
105
106
Takes a string of the form "DD-MM-YYYY" (or anything separated by
107
dashes), converts it to the form "YYYY/MM/DD", and returns the result.
108
109
=cut
110
111
sub slashifyDate {
112
113
    # accepts a date of the form xx-xx-xx[xx] and returns it in the
114
    # form xx/xx/xx[xx]
115
    my @dateOut = split( '-', shift );
116
    return ("$dateOut[2]/$dateOut[1]/$dateOut[0]");
117
}
118
119
# FIXME.. this should be moved to a MARC-specific module
101
# FIXME.. this should be moved to a MARC-specific module
120
sub subfield_is_koha_internal_p {
102
sub subfield_is_koha_internal_p {
121
    my ($subfield) = @_;
103
    my ($subfield) = @_;
(-)a/t/Koha.t (-8 / +1 lines)
Lines 25-31 use Module::Load::Conditional qw/check_install/; Link Here
25
25
26
BEGIN {
26
BEGIN {
27
    if ( check_install( module => 'Test::DBIx::Class' ) ) {
27
    if ( check_install( module => 'Test::DBIx::Class' ) ) {
28
        plan tests => 34;
28
        plan tests => 33;
29
    } else {
29
    } else {
30
        plan skip_all => "Need Test::DBIx::Class"
30
        plan skip_all => "Need Test::DBIx::Class"
31
    }
31
    }
Lines 63-80 is ( IsAuthorisedValueCategory('LOC'), 1, 'LOC is a valid authorized value categ Link Here
63
is ( IsAuthorisedValueCategory('something'), 0, 'something is not a valid authorized value category');
63
is ( IsAuthorisedValueCategory('something'), 0, 'something is not a valid authorized value category');
64
is ( IsAuthorisedValueCategory('RELTERMS'), 1, 'RELTERMS is a valid authorized value category');
64
is ( IsAuthorisedValueCategory('RELTERMS'), 1, 'RELTERMS is a valid authorized value category');
65
65
66
#
67
# test that &slashifyDate returns correct (non-US) date
68
#
69
my $date = "01/01/2002";
70
my $newdate = &slashifyDate("2002-01-01");
71
my $isbn13 = "9780330356473";
66
my $isbn13 = "9780330356473";
72
my $isbn13D = "978-0-330-35647-3";
67
my $isbn13D = "978-0-330-35647-3";
73
my $isbn10 = "033035647X";
68
my $isbn10 = "033035647X";
74
my $isbn10D = "0-330-35647-X";
69
my $isbn10D = "0-330-35647-X";
75
70
76
ok($date eq $newdate, 'slashifyDate');
77
78
my $undef = undef;
71
my $undef = undef;
79
is(xml_escape($undef), '', 'xml_escape() returns empty string on undef input');
72
is(xml_escape($undef), '', 'xml_escape() returns empty string on undef input');
80
my $str = q{'"&<>'};
73
my $str = q{'"&<>'};
(-)a/t/db_dependent/Koha.t (-11 / +3 lines)
Lines 203-223 $dbh->do($sql); Link Here
203
}
203
}
204
204
205
205
206
#
206
subtest 'ISBN tests' => sub {
207
# test that &slashifyDate returns correct (non-US) date
207
    plan tests => 6;
208
#
209
subtest 'Date and ISBN tests' => sub {
210
    plan tests => 7;
211
208
212
    my $date    = "01/01/2002";
213
    my $newdate = &slashifyDate("2002-01-01");
214
    my $isbn13  = "9780330356473";
209
    my $isbn13  = "9780330356473";
215
    my $isbn13D = "978-0-330-35647-3";
210
    my $isbn13D = "978-0-330-35647-3";
216
    my $isbn10  = "033035647X";
211
    my $isbn10  = "033035647X";
217
    my $isbn10D = "0-330-35647-X";
212
    my $isbn10D = "0-330-35647-X";
218
    ok( $date eq $newdate, 'slashifyDate' );
213
    is( xml_escape(undef), '',
219
    my $undef = undef;
220
    is( xml_escape($undef), '',
221
        'xml_escape() returns empty string on undef input' );
214
        'xml_escape() returns empty string on undef input' );
222
    my $str = q{'"&<>'};
215
    my $str = q{'"&<>'};
223
    is(
216
    is(
224
- 

Return to bug 15769