You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Stas Bekman <st...@stason.org> on 2002/01/29 18:55:14 UTC

[patch take2] ht_time interface

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


Re: [patch take2] ht_time interface

Posted by Doug MacEachern <do...@covalent.net>.
On Wed, 30 Jan 2002, Stas Bekman wrote:
 
> What do you mean?

if ap_ht_time changes to apr_date_format_http, then Apache::Time::ht_time
changes to APR::Date::format_http.


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


Re: [patch take2] ht_time interface

Posted by Stas Bekman <st...@stason.org>.
Doug MacEachern wrote:

> On Wed, 30 Jan 2002, Stas Bekman wrote:
> 
> 
>>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
>>
> 
> looks good, but don't you think the move should be suggested to apr-dev,
> ap_ht_time => apr_date_format_http:


of course, I've posted this before I read your suggestion.


> 
>>+        my $time_str = Apache::Time::ht_time($r->pool, $time_sec, $fmt, 1);
>>
>                           APR::Date::format_http(...)
> 
> 
>>+        ok t_cmp(APR::Date::parse_http($time_str),
>>
> 
> ?

What do you mean?


_____________________________________________________________________
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


Re: [patch take2] ht_time interface

Posted by Doug MacEachern <do...@covalent.net>.
On Wed, 30 Jan 2002, Stas Bekman wrote:

> 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

looks good, but don't you think the move should be suggested to apr-dev,
ap_ht_time => apr_date_format_http:

> +        my $time_str = Apache::Time::ht_time($r->pool, $time_sec, $fmt, 1);
                          APR::Date::format_http(...)

> +        ok t_cmp(APR::Date::parse_http($time_str),

?


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