Fix regressions in IC::DT registration logic
[dbsrgits/DBIx-Class.git] / t / inflate / datetime_pg.t
CommitLineData
40f75181 1use strict;
2use warnings;
3
4use Test::More;
49bceca3 5use Test::Warn;
40f75181 6use lib qw(t/lib);
7use DBICTest;
8
68de9438 9plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt_pg')
10 unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt_pg');
11
40f75181 12{
13 local $SIG{__WARN__} = sub { warn @_ if $_[0] !~ /extra \=\> .+? has been deprecated/ };
14 DBICTest::Schema->load_classes('EventTZPg');
15}
16
40f75181 17my $schema = DBICTest->init_schema();
18
49bceca3 19warnings_are {
40f75181 20 my $event = $schema->resultset("EventTZPg")->find(1);
21 $event->update({created_on => '2009-01-15 17:00:00+00'});
22 $event->discard_changes;
23 isa_ok($event->created_on, "DateTime") or diag $event->created_on;
24 is($event->created_on->time_zone->name, "America/Chicago", "Timezone changed");
25 # Time zone difference -> -6hours
26 is($event->created_on->iso8601, "2009-01-15T11:00:00", "Time with TZ correct");
65b386df 27
28# test 'timestamp without time zone'
29 my $dt = DateTime->from_epoch(epoch => time);
30 $dt->set_nanosecond(int 500_000_000);
31 $event->update({ts_without_tz => $dt});
32 $event->discard_changes;
33 isa_ok($event->ts_without_tz, "DateTime") or diag $event->created_on;
34 is($event->ts_without_tz, $dt, 'timestamp without time zone inflation');
35 is($event->ts_without_tz->microsecond, $dt->microsecond,
36 'timestamp without time zone microseconds survived');
49bceca3 37} [], 'No warnings during DT manipulations';
68de9438 38
39done_testing;