Fix overspecified msaccess test optdep (should not include icdt)
[dbsrgits/DBIx-Class.git] / t / inflate / datetime_pg.t
1 use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_dt_pg';
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7 use Test::Warn;
8 use lib qw(t/lib);
9 use DBICTest;
10
11 DBICTest::Schema->load_classes('EventTZPg');
12
13 my $schema = DBICTest->init_schema();
14
15 warnings_are {
16   my $event = $schema->resultset("EventTZPg")->find(1);
17   $event->update({created_on => '2009-01-15 17:00:00+00'});
18   $event->discard_changes;
19   isa_ok($event->created_on, "DateTime") or diag $event->created_on;
20   is($event->created_on->time_zone->name, "America/Chicago", "Timezone changed");
21   # Time zone difference -> -6hours
22   is($event->created_on->iso8601, "2009-01-15T11:00:00", "Time with TZ correct");
23
24 # test 'timestamp without time zone'
25   my $dt = DateTime->from_epoch(epoch => time);
26   $dt->set_nanosecond(int 500_000_000);
27   $event->update({ts_without_tz => $dt});
28   $event->discard_changes;
29   isa_ok($event->ts_without_tz, "DateTime") or diag $event->created_on;
30   is($event->ts_without_tz, $dt, 'timestamp without time zone inflation');
31   is($event->ts_without_tz->microsecond, $dt->microsecond,
32     'timestamp without time zone microseconds survived');
33 } [], 'No warnings during DT manipulations';
34
35 done_testing;