IC::DT changes:
[dbsrgits/DBIx-Class.git] / t / inflate / datetime_pg.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use lib qw(t/lib);
6 use DBICTest;
7
8 {
9   local $SIG{__WARN__} = sub { warn @_ if $_[0] !~ /extra \=\> .+? has been deprecated/ };
10   DBICTest::Schema->load_classes('EventTZPg');
11 }
12
13 eval { require DateTime::Format::Pg };
14 plan $@
15   ? ( skip_all =>  'Need DateTime::Format::Pg for timestamp inflation tests')
16   : ( tests => 3 )
17 ;
18
19
20 my $schema = DBICTest->init_schema();
21
22 {
23   my $event = $schema->resultset("EventTZPg")->find(1);
24   $event->update({created_on => '2009-01-15 17:00:00+00'});
25   $event->discard_changes;
26   isa_ok($event->created_on, "DateTime") or diag $event->created_on;
27   is($event->created_on->time_zone->name, "America/Chicago", "Timezone changed");
28   # Time zone difference -> -6hours
29   is($event->created_on->iso8601, "2009-01-15T11:00:00", "Time with TZ correct");
30 }