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 100-122 Koha.pm provides many functions for Koha scripts. Link Here
100
99
101
=cut
100
=cut
102
101
103
=head2 slashifyDate
104
105
  $slash_date = &slashifyDate($dash_date);
106
107
Takes a string of the form "DD-MM-YYYY" (or anything separated by
108
dashes), converts it to the form "YYYY/MM/DD", and returns the result.
109
110
=cut
111
112
sub slashifyDate {
113
114
    # accepts a date of the form xx-xx-xx[xx] and returns it in the
115
    # form xx/xx/xx[xx]
116
    my @dateOut = split( '-', shift );
117
    return ("$dateOut[2]/$dateOut[1]/$dateOut[0]");
118
}
119
120
# FIXME.. this should be moved to a MARC-specific module
102
# FIXME.. this should be moved to a MARC-specific module
121
sub subfield_is_koha_internal_p {
103
sub subfield_is_koha_internal_p {
122
    my ($subfield) = @_;
104
    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 204-224 $dbh->do($sql); Link Here
204
}
204
}
205
205
206
206
207
#
207
subtest 'ISBN tests' => sub {
208
# test that &slashifyDate returns correct (non-US) date
208
    plan tests => 6;
209
#
210
subtest 'Date and ISBN tests' => sub {
211
    plan tests => 7;
212
209
213
    my $date    = "01/01/2002";
214
    my $newdate = &slashifyDate("2002-01-01");
215
    my $isbn13  = "9780330356473";
210
    my $isbn13  = "9780330356473";
216
    my $isbn13D = "978-0-330-35647-3";
211
    my $isbn13D = "978-0-330-35647-3";
217
    my $isbn10  = "033035647X";
212
    my $isbn10  = "033035647X";
218
    my $isbn10D = "0-330-35647-X";
213
    my $isbn10D = "0-330-35647-X";
219
    ok( $date eq $newdate, 'slashifyDate' );
214
    is( xml_escape(undef), '',
220
    my $undef = undef;
221
    is( xml_escape($undef), '',
222
        'xml_escape() returns empty string on undef input' );
215
        'xml_escape() returns empty string on undef input' );
223
    my $str = q{'"&<>'};
216
    my $str = q{'"&<>'};
224
    is(
217
    is(
225
- 

Return to bug 15769