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