Massive cleanup of DateTime test dependencies, other interim
[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
68de9438 8plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt_pg')
9 unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt_pg');
10
40f75181 11{
12 local $SIG{__WARN__} = sub { warn @_ if $_[0] !~ /extra \=\> .+? has been deprecated/ };
13 DBICTest::Schema->load_classes('EventTZPg');
14}
15
40f75181 16my $schema = DBICTest->init_schema();
17
18{
19 my $event = $schema->resultset("EventTZPg")->find(1);
20 $event->update({created_on => '2009-01-15 17:00:00+00'});
21 $event->discard_changes;
22 isa_ok($event->created_on, "DateTime") or diag $event->created_on;
23 is($event->created_on->time_zone->name, "America/Chicago", "Timezone changed");
24 # Time zone difference -> -6hours
25 is($event->created_on->iso8601, "2009-01-15T11:00:00", "Time with TZ correct");
65b386df 26
27# test 'timestamp without time zone'
28 my $dt = DateTime->from_epoch(epoch => time);
29 $dt->set_nanosecond(int 500_000_000);
30 $event->update({ts_without_tz => $dt});
31 $event->discard_changes;
32 isa_ok($event->ts_without_tz, "DateTime") or diag $event->created_on;
33 is($event->ts_without_tz, $dt, 'timestamp without time zone inflation');
34 is($event->ts_without_tz->microsecond, $dt->microsecond,
35 'timestamp without time zone microseconds survived');
40f75181 36}
68de9438 37
38done_testing;