perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject [patch take2] ht_time interface
Date Tue, 29 Jan 2002 17:55:14 GMT
Here is the new patch that picks the default_pool in compat.pm from 
Apache->request, per our recent discussion.

- interface to Apache::Time::ht_time
- compat wrapper Apache::Util::ht_time
- tests for Apache::Time::ht_time and the wrapper Apache::Util

Index: xs/maps/apache_functions.map
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/maps/apache_functions.map,v
retrieving revision 1.43
diff -u -r1.43 apache_functions.map
--- xs/maps/apache_functions.map	25 Jan 2002 04:04:22 -0000	1.43
+++ xs/maps/apache_functions.map	29 Jan 2002 17:52:37 -0000
@@ -255,8 +255,10 @@
  -ap_set_string_slot_lower
  -ap_set_deprecated

+MODULE=Apache::Time
+ ap_ht_time | | p, t=TIME_NOW, fmt=DEFAULT_TIME_FORMAT, gmt=TRUE
+
  MODULE=Apache::Util
- ap_ht_time
  !ap_rfc1413
   ap_escape_html
   #escape_uri
--- /dev/null	Thu Jan  1 07:30:00 1970
+++ t/response/TestApache/time.pm	Wed Jan 30 01:48:11 2002
@@ -0,0 +1,46 @@
+package TestApache::time;
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestUtil;
+use Apache::Const -compile => 'OK';
+
+use Apache::Time ();
+use APR::Pool ();
+use APR::Date ();
+
+my @formats = (
+    '%a, %d %b %Y %H:%M:%S %Z',
+    '%A, %d-%b-%y %H:%M:%S %Z',
+);
+
+sub handler {
+    my $r = shift;
+
+    plan $r, tests => 6;
+
+    # basic tests, hard to verify because of the timezone being the
+    # last arg, so without setting it to true we cannot verify data
+    t_debug("basic Apache::Time::ht_time tests");
+    ok Apache::Time::ht_time($r->pool);
+    ok Apache::Time::ht_time($r->pool, time);
+    ok Apache::Time::ht_time($r->pool, time, '%d %b %Y');
+    ok Apache::Time::ht_time($r->pool, time, '%d %b %Y', 0);
+
+    my $time_sec = time;
+    for my $fmt (@formats) {
+        my $time_str = Apache::Time::ht_time($r->pool, $time_sec, $fmt, 1);
+        ok t_cmp(APR::Date::parse_http($time_str),
+                 $time_sec,
+                 "Apache::Time::ht_time / $time_str"
+                );
+    }
+
+    Apache::OK;
+}
+
+1;
+__END__
+
--- /dev/null	Thu Jan  1 07:30:00 1970
+++ xs/Apache/Time/Apache__Time.h	Tue Jan 29 16:23:01 2002
@@ -0,0 +1,5 @@
+#define TIME_NOW apr_time_now()
+
+#define DEFAULT_TIME_FORMAT "%A, %d-%b-%Y %H:%M:%S %Z"
+
+


_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message