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

(-)a/t/DateUtils.t (-6 / +5 lines)
Lines 144-150 like( $@, qr/.*does not match the date format \(rfc3339\).*/, 'dt_from_string sh Link Here
144
144
145
# ISO string tests
145
# ISO string tests
146
subtest 'dt_from_string - iso format' => sub {
146
subtest 'dt_from_string - iso format' => sub {
147
    plan tests => 6;
147
    plan tests => 5;
148
148
149
    my $module_context = Test::MockModule->new('C4::Context');
149
    my $module_context = Test::MockModule->new('C4::Context');
150
    $module_context->mock(
150
    $module_context->mock(
Lines 157-162 subtest 'dt_from_string - iso format' => sub { Link Here
157
    # Dateonly
157
    # Dateonly
158
    my $dt_iso = dt_from_string( '2012-01-01', 'iso' );
158
    my $dt_iso = dt_from_string( '2012-01-01', 'iso' );
159
    cmp_ok( $dt_iso->epoch(), 'eq', '1325372400', 'dt_from_string handles dateonly string' );
159
    cmp_ok( $dt_iso->epoch(), 'eq', '1325372400', 'dt_from_string handles dateonly string' );
160
    # Saturday December 31, 2011 23:00:00 (UTC) == Sunday January 01, 2012 00:00:00 Europe/Paris (CET/+01:00)
160
161
161
    eval {
162
    eval {
162
        $dt_iso = dt_from_string( '2012-01-32', 'iso' );
163
        $dt_iso = dt_from_string( '2012-01-32', 'iso' );
Lines 166-182 subtest 'dt_from_string - iso format' => sub { Link Here
166
    # Datetime
167
    # Datetime
167
    $dt_iso = dt_from_string( '2012-01-01T23:59:59', 'iso' );
168
    $dt_iso = dt_from_string( '2012-01-01T23:59:59', 'iso' );
168
    cmp_ok( $dt_iso->epoch(), 'eq', '1325458799', 'dt_from_string with no offset assumes "local"' );
169
    cmp_ok( $dt_iso->epoch(), 'eq', '1325458799', 'dt_from_string with no offset assumes "local"' );
170
    # Sunday January 01, 2012 22:59:59 (UTC) == Sunday January 01, 2012 23:59:59 Europe/Paris (CET/+01:00)
169
171
170
    # Datetime with timezone
172
    # Datetime with timezone
171
    $dt_iso = dt_from_string( '2012-01-01T23:59:59Z', 'iso' );
173
    $dt_iso = dt_from_string( '2012-01-01T23:59:59Z', 'iso' );
172
    cmp_ok( $dt_iso->epoch(), 'eq', '1325462399', 'dt_from_string with UTC prescribed as Z' );
174
    cmp_ok( $dt_iso->epoch(), 'eq', '1325462399', 'dt_from_string with UTC prescribed as Z' );
175
    # Sunday January 01, 2012 23:59:59 (UTC)
173
176
174
    $dt_iso = dt_from_string( '2012-01-01T23:59:59+02:00', 'iso' );
177
    $dt_iso = dt_from_string( '2012-01-01T23:59:59+02:00', 'iso' );
175
    cmp_ok( $dt_iso->epoch(), 'eq', '1325455199', 'dt_from_string with offset' );
178
    cmp_ok( $dt_iso->epoch(), 'eq', '1325455199', 'dt_from_string with offset' );
176
179
    # Sunday January 01, 2012 21:59:59 (UTC) == Sunday January 01, 2012 23:59:59 Europe/Athens (EET/+02:00)
177
    $dt_iso = dt_from_string( '2012-01-01T23:59:59+02:00', 'iso' );
178
    cmp_ok( $dt_iso->epoch(), 'eq', '1325455199', 'dt_from_string handles an offset' );
179
180
};
180
};
181
181
182
# Return undef if passed mysql 0 dates
182
# Return undef if passed mysql 0 dates
183
- 

Return to bug 29718