Commit | Line | Data |
40f75181 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
49bceca3 |
5 | use Test::Warn; |
199fbc45 |
6 | use DBIx::Class::Optional::Dependencies (); |
40f75181 |
7 | use lib qw(t/lib); |
8 | use DBICTest; |
9 | |
68de9438 |
10 | plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt_pg') |
11 | unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt_pg'); |
12 | |
052a832c |
13 | DBICTest::Schema->load_classes('EventTZPg'); |
40f75181 |
14 | |
40f75181 |
15 | my $schema = DBICTest->init_schema(); |
16 | |
8bb84304 |
17 | # this may generate warnings under certain CI flags, hence do it outside of |
18 | # the warnings_are below |
19 | my $dt = DateTime->new( year => 2000, time_zone => "America/Chicago" ); |
20 | |
49bceca3 |
21 | warnings_are { |
40f75181 |
22 | my $event = $schema->resultset("EventTZPg")->find(1); |
23 | $event->update({created_on => '2009-01-15 17:00:00+00'}); |
24 | $event->discard_changes; |
25 | isa_ok($event->created_on, "DateTime") or diag $event->created_on; |
26 | is($event->created_on->time_zone->name, "America/Chicago", "Timezone changed"); |
27 | # Time zone difference -> -6hours |
28 | is($event->created_on->iso8601, "2009-01-15T11:00:00", "Time with TZ correct"); |
65b386df |
29 | |
30 | # test 'timestamp without time zone' |
31 | my $dt = DateTime->from_epoch(epoch => time); |
32 | $dt->set_nanosecond(int 500_000_000); |
33 | $event->update({ts_without_tz => $dt}); |
34 | $event->discard_changes; |
35 | isa_ok($event->ts_without_tz, "DateTime") or diag $event->created_on; |
36 | is($event->ts_without_tz, $dt, 'timestamp without time zone inflation'); |
37 | is($event->ts_without_tz->microsecond, $dt->microsecond, |
38 | 'timestamp without time zone microseconds survived'); |
49bceca3 |
39 | } [], 'No warnings during DT manipulations'; |
68de9438 |
40 | |
41 | done_testing; |