[Rt-commit] rt branch, 4.2/relative-time-parsing-tests, created. rt-4.0.6-335-gf244493
Ruslan Zakirov
ruz at bestpractical.com
Fri Jun 15 12:43:03 EDT 2012
The branch, 4.2/relative-time-parsing-tests has been created
at f244493bb1eb47c94a43004f9ae33d1e1f392d32 (commit)
- Log -----------------------------------------------------------------
commit f244493bb1eb47c94a43004f9ae33d1e1f392d32
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri Jun 15 20:38:54 2012 +0400
test parsing 'tomorrow 10am' with different TZs
Make sure we properly parse the time with positive/negative timezones
and day in tested zone is different from UTC
diff --git a/t/api/date.t b/t/api/date.t
index 6bc0c64..0405b0f 100644
--- a/t/api/date.t
+++ b/t/api/date.t
@@ -3,7 +3,7 @@ use Test::MockTime qw(set_fixed_time restore_time);
use DateTime;
use warnings; use strict;
-use RT::Test tests => 173;
+use RT::Test tests => 177;
use RT::User;
use Test::Warn;
@@ -56,7 +56,7 @@ my $current_user;
is($date->Timezone('user'),
'Europe/Moscow',
"in user context still returns user's timezone");
-
+
$current_user->UserObj->__Set( Field => 'Timezone', Value => '');
is_empty($current_user->UserObj->Timezone,
"successfuly changed user's timezone");
@@ -359,6 +359,34 @@ my $year = (localtime(time))[5] + 1900;
is($date->ISO, '2005-11-28 15:10:00', "YYYY-DD-MM hh:mm:ss");
}
+{ # 'tomorrow 10am' with TZ
+ $current_user->UserObj->__Set( Field => 'Timezone', Value => 'Europe/Moscow');
+
+ set_fixed_time("2012-06-14T15:10:00Z"); # 14th in UTC and Moscow
+ my $date = RT::Date->new( $current_user );
+ $date->Set(Format => 'unknown', Value => 'tomorrow 10am');
+ is($date->ISO, '2012-06-15 06:00:00', "YYYY-DD-MM hh:mm:ss");
+
+ set_fixed_time("2012-06-13T23:10:00Z"); # 13th in UTC and 14th in Moscow
+ my $date = RT::Date->new( $current_user );
+ $date->Set(Format => 'unknown', Value => 'tomorrow 10am');
+ is($date->ISO, '2012-06-15 06:00:00', "YYYY-DD-MM hh:mm:ss");
+
+ $current_user->UserObj->__Set( Field => 'Timezone', Value => 'US/Hawaii');
+
+ set_fixed_time("2012-06-14T20:10:00Z"); # 14th in UTC and Hawaii
+ my $date = RT::Date->new( $current_user );
+ $date->Set(Format => 'unknown', Value => 'tomorrow 10am');
+ is($date->ISO, '2012-06-15 20:00:00', "YYYY-DD-MM hh:mm:ss");
+
+ set_fixed_time("2012-06-15T05:10:00Z"); # 15th in UTC and 14th in Hawaii
+ my $date = RT::Date->new( $current_user );
+ $date->Set(Format => 'unknown', Value => 'tomorrow 10am');
+ is($date->ISO, '2012-06-15 20:00:00', "YYYY-DD-MM hh:mm:ss");
+
+ restore_time();
+}
+
{ # SetToMidnight
my $date = RT::Date->new(RT->SystemUser);
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list