Enable pg test disabled god knows why, minor cleanup.
[dbsrgits/DBIx-Class.git] / t / inflate / datetime_pg.t
CommitLineData
40f75181 1use strict;
2use warnings;
3
4use Test::More;
5use lib qw(t/lib);
6use DBICTest;
7
8{
9 local $SIG{__WARN__} = sub { warn @_ if $_[0] !~ /extra \=\> .+? has been deprecated/ };
10 DBICTest::Schema->load_classes('EventTZPg');
11}
12
13eval { require DateTime::Format::Pg };
14plan $@
15 ? ( skip_all => 'Need DateTime::Format::Pg for timestamp inflation tests')
65b386df 16 : ( tests => 6 )
40f75181 17;
18
19
20my $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");
65b386df 30
31# test 'timestamp without time zone'
32 my $dt = DateTime->from_epoch(epoch => time);
33 $dt->set_nanosecond(int 500_000_000);
34 $event->update({ts_without_tz => $dt});
35 $event->discard_changes;
36 isa_ok($event->ts_without_tz, "DateTime") or diag $event->created_on;
37 is($event->ts_without_tz, $dt, 'timestamp without time zone inflation');
38 is($event->ts_without_tz->microsecond, $dt->microsecond,
39 'timestamp without time zone microseconds survived');
40f75181 40}