#!/usr/bin/env perl use strict; use warnings; use Test::More ('no_plan'); use Time::Piece; $ENV{'TZ'} = 'America/Los_Angeles'; my @tests = ( ['2017-06-19 10:07:42', '%Y-%m-%d %H:%M:%S'], ['2017-06-19 10:07:42-0700', '%Y-%m-%d %H:%M:%S%z'], ); is($Time::Piece::VERSION, 1.31); foreach my $test (@tests) { my ($datestr, $fmt) = @$test; my $t = localtime->strptime($datestr, $fmt); is($t->epoch, 1497892062); is($t->tzoffset, -25200); is($t->strftime, 'Mon, 19 Jun 2017 10:07:42 PDT'); is($t->strftime('%Y-%m-%d %H:%M:%S'), $datestr); }