[Rt-commit] r18677 - in rt/3.999/trunk: .
sartak at bestpractical.com
sartak at bestpractical.com
Wed Mar 4 20:35:23 EST 2009
Author: sartak
Date: Wed Mar 4 20:35:23 2009
New Revision: 18677
Modified:
rt/3.999/trunk/ (props changed)
rt/3.999/trunk/t/api/date.t
Log:
r80932 at onn: sartak | 2009-03-04 20:35:14 -0500
Various text fixes
Modified: rt/3.999/trunk/t/api/date.t
==============================================================================
--- rt/3.999/trunk/t/api/date.t (original)
+++ rt/3.999/trunk/t/api/date.t Wed Mar 4 20:35:23 2009
@@ -129,100 +129,109 @@
is($date->rfc2822( time_zone => 'user' ), 'Fri, 01 Jul 2005 11:10:00 -0400', "RFC2822");
}
-{ # setting value via Unix method
+{ # setting value via from_epoch method
my $date = RT::DateTime->from_epoch(epoch => 1, time_zone => 'UTC');
is($date->time_zone->name, 'UTC', "time_zone set correctly");
- is($date->iso, '1970-01-01 00:00:01', "correct value");
+ is($date, '1970-01-01 00:00:01', "correct value");
$date = RT::DateTime->from_epoch(epoch => 1);
is($date->time_zone->name, 'America/New_York', "time_zone defaults to user's");
- is($date->iso, '1969-12-31 19:00:01', "correct value");
+ is($date, '1969-12-31 19:00:01', "correct value");
}
{ # set+ISO format
- my $date = RT::DateTime->now(current_user => RT->system_user);
- my $return = $date->set(format => 'ISO', value => 'weird date');
- is ($return, undef, "The set failed. returned undef");
- is($date->epoch, undef, "date was wrong => unix == 0");
-
- # XXX: ISO format has more feature than we suport
- # http://www.cl.cam.ac.uk/~mgk25/iso-time.html
-
- $date->set(format => 'ISO', value => '2005-11-28 15:10:00');
- is($date->iso, '2005-11-28 15:10:00', "YYYY-DD-MM hh:mm:ss");
-
- $date->set(format => 'ISO', value => '2005-11-28 15:10:00+00');
- is($date->iso, '2005-11-28 15:10:00', "YYYY-DD-MM hh:mm:ss+00");
+ my $date = RT::DateTime->new_from_string('weird date');
+ is($date, undef, "unparseable date returns undef");
- $date->set(format => 'ISO', value => '11-28 15:10:00');
- is($date->iso, '2005-11-28 15:10:00', "DD-MM hh:mm:ss");
+ $date = RT::DateTime->new_from_string('2005-11-28 15:10:00');
+ is($date, '2005-11-28 15:10:00', "YYYY-DD-MM hh:mm:ss");
- $date->set(format => 'ISO', value => '11-28 15:10:00+00');
- is($date->iso, '2005-11-28 15:10:00', "DD-MM hh:mm:ss+00");
+ TODO: {
+ local $TODO = "YYYY-DD-MM hh:mm:ss+00 not handled yet";
+ $date = RT::DateTime->new_from_string('2005-11-28 15:10:00+00');
+ is($date, '2005-11-28 15:10:00', "YYYY-DD-MM hh:mm:ss+00");
+ };
+
+ TODO: {
+ local $TODO = "DD-MM hh:mm:ss not handled yet";
+ $date = RT::DateTime->new_from_string('11-28 15:10:00');
+ is($date, '2005-11-28 15:10:00', "DD-MM hh:mm:ss");
+ };
+
+ TODO: {
+ local $TODO = "DD-MM hh:mm:ss+00 not handled yet";
+ $date = RT::DateTime->new_from_string('11-28 15:10:00+00');
+ is($date, '2005-11-28 15:10:00', "DD-MM hh:mm:ss+00");
+ };
+
+ $date = RT::DateTime->new_from_string('20051128151000');
+ is($date, '2005-11-28 15:10:00', "YYYYDDMMhhmmss");
+
+ TODO: {
+ local $TODO = "DDMMhhmmss not handled yet";
+ $date = RT::DateTime->new_from_string('1128151000');
+ is($date, '2005-11-28 15:10:00', "DDMMhhmmss");
+ };
+
+ $date = RT::DateTime->new_from_string('2005112815:10:00');
+ is($date, '2005-11-28 15:10:00', "YYYYDDMMhh:mm:ss");
+
+ TODO: {
+ local $TODO = "DDMMhh:mm:ss not handled yet";
+ $date = RT::DateTime->new_from_string('112815:10:00');
+ is($date, '2005-11-28 15:10:00', "DDMMhh:mm:ss");
+ };
- $date->set(format => 'ISO', value => '20051128151000');
- is($date->iso, '2005-11-28 15:10:00', "YYYYDDMMhhmmss");
+ $date = RT::DateTime->new_from_string('2005-13-28 15:10:00');
+ ok(!$date, "wrong month value");
- $date->set(format => 'ISO', value => '1128151000');
- is($date->iso, '2005-11-28 15:10:00', "DDMMhhmmss");
+ $date = RT::DateTime->new_from_string('2005-00-28 15:10:00');
+ ok(!$date, "wrong month value");
- $date->set(format => 'ISO', value => '2005112815:10:00');
- is($date->iso, '2005-11-28 15:10:00', "YYYYDDMMhh:mm:ss");
-
- $date->set(format => 'ISO', value => '112815:10:00');
- is($date->iso, '2005-11-28 15:10:00', "DDMMhh:mm:ss");
-
- $date->set(format => 'ISO', value => '2005-13-28 15:10:00');
- is($date->epoch, 0, "wrong month value");
-
- $date->set(format => 'ISO', value => '2005-00-28 15:10:00');
- is($date->epoch, 0, "wrong month value");
-
- $date->set(format => 'ISO', value => '1960-01-28 15:10:00');
- is($date->epoch, 0, "too old, we don't support");
+ $date = RT::DateTime->new_from_string('1960-01-28 15:10:00');
+ is($date, '1960-01-28 15:10:00', "we can support pre-1970s dates now");
}
{ # set+datemanip format(time::ParseDate)
RT->config->set( TimeZone => 'Europe/Moscow' );
- $date->set(format => 'datemanip', value => '2005-11-28 15:10:00');
+ my $date = RT::DateTime->new_from_string('2005-11-28 15:10:00');
is($date->iso, '2005-11-28 12:10:00', "YYYY-DD-MM hh:mm:ss");
RT->config->set( TimeZone => 'UTC' );
- $date->set(format => 'datemanip', value => '2005-11-28 15:10:00');
+ $date = RT::DateTime->new_from_string('2005-11-28 15:10:00');
is($date->iso, '2005-11-28 15:10:00', "YYYY-DD-MM hh:mm:ss");
$current_user->user_object->__set( column => 'time_zone', value => 'Europe/Moscow');
- $date = RT::DateTime->now;
- $date->set(format => 'datemanip', value => '2005-11-28 15:10:00');
+ $date = RT::DateTime->new_from_string('2005-11-28 15:10:00');
is($date->iso, '2005-11-28 12:10:00', "YYYY-DD-MM hh:mm:ss");
}
{ # set+unknown format(time::ParseDate)
RT->config->set( TimeZone => 'Europe/Moscow' );
- $date->set(format => 'unknown', value => '2005-11-28 15:10:00');
+ my $date = RT::DateTime->new_from_string('2005-11-28 15:10:00');
is($date->iso, '2005-11-28 12:10:00', "YYYY-DD-MM hh:mm:ss");
- $date->set(format => 'unknown', value => '2005-11-28 15:10:00', time_zone => 'utc' );
+ $date = RT::DateTime->new_from_string('2005-11-28 15:10:00', time_zone => 'UTC' );
is($date->iso, '2005-11-28 15:10:00', "YYYY-DD-MM hh:mm:ss");
# relative dates
- $date->set(format => 'unknown', value => 'now');
+ $date = RT::DateTime->new_from_string('now');
is($date->iso, '2005-11-28 15:10:00', "YYYY-DD-MM hh:mm:ss");
- $date->set(format => 'unknown', value => '1 day ago');
+ $date = RT::DateTime->new_from_string('1 day ago');
is($date->iso, '2005-11-27 15:10:00', "YYYY-DD-MM hh:mm:ss");
RT->config->set( TimeZone => 'UTC' );
- $date->set(format => 'unknown', value => '2005-11-28 15:10:00');
+ $date = RT::DateTime->new_from_string('2005-11-28 15:10:00');
is($date->iso, '2005-11-28 15:10:00', "YYYY-DD-MM hh:mm:ss");
$current_user->user_object->__set( column => 'time_zone', value => 'Europe/Moscow');
$date = RT::DateTime->now;
- $date->set(format => 'unknown', value => '2005-11-28 15:10:00');
+ $date = RT::DateTime->new_from_string('2005-11-28 15:10:00');
is($date->iso, '2005-11-28 12:10:00', "YYYY-DD-MM hh:mm:ss");
- $date->set(format => 'unknown', value => '2005-11-28 15:10:00', time_zone => 'server' );
+ $date = RT::DateTime->new_from_string('2005-11-28 15:10:00', time_zone => 'server' );
is($date->iso, '2005-11-28 15:10:00', "YYYY-DD-MM hh:mm:ss");
- $date->set(format => 'unknown', value => '2005-11-28 15:10:00', time_zone => 'utc' );
+ $date = RT::DateTime->new_from_string('2005-11-28 15:10:00', time_zone => 'UTC' );
is($date->iso, '2005-11-28 15:10:00', "YYYY-DD-MM hh:mm:ss");
}
More information about the Rt-commit
mailing list