1 use DBIx::Class::Optional::Dependencies -skip_all_without => qw( ic_dt_pg );
11 DBICTest::Schema->load_classes('EventTZPg');
14 my $s = DBICTest::Schema->connect('dbi:Pg:whatever');
16 ok (!$s->storage->_dbh, 'definitely not connected');
18 # Check that datetime_parser returns correctly before we explicitly connect.
19 my $store = ref $s->storage;
20 is($store, 'DBIx::Class::Storage::DBI', 'Started with generic storage');
22 my $parser = $s->storage->datetime_parser;
23 is( $parser, 'DateTime::Format::Pg', 'datetime_parser is as expected');
25 ok (!$s->storage->_dbh, 'still not connected');
28 my $schema = DBICTest->init_schema();
30 # this may generate warnings under certain CI flags, hence do it outside of
31 # the warnings_are below
32 my $dt = DateTime->new( year => 2000, time_zone => "America/Chicago" );
35 my $event = $schema->resultset("EventTZPg")->find(1);
36 $event->update({created_on => '2009-01-15 17:00:00+00'});
37 $event->discard_changes;
38 isa_ok($event->created_on, "DateTime") or diag $event->created_on;
39 is($event->created_on->time_zone->name, "America/Chicago", "Timezone changed");
40 # Time zone difference -> -6hours
41 is($event->created_on->iso8601, "2009-01-15T11:00:00", "Time with TZ correct");
43 # test 'timestamp without time zone'
44 my $dt = DateTime->from_epoch(epoch => time);
45 $dt->set_nanosecond(int 500_000_000);
46 $event->update({ts_without_tz => $dt});
47 $event->discard_changes;
48 isa_ok($event->ts_without_tz, "DateTime") or diag $event->created_on;
49 is($event->ts_without_tz, $dt, 'timestamp without time zone inflation');
50 is($event->ts_without_tz->microsecond, $dt->microsecond,
51 'timestamp without time zone microseconds survived');
52 } [], 'No warnings during DT manipulations';