summaryrefslogtreecommitdiff
path: root/test/testtime.c
diff options
context:
space:
mode:
authorDavid Reid <dreid@apache.org>2001-04-04 00:45:13 +0000
committerDavid Reid <dreid@apache.org>2001-04-04 00:45:13 +0000
commit171fcbd6a5059a3a97f2b3662d9a5a6b935c97d5 (patch)
tree4af8fb73070f81634d8d4f4a4d29a29fef46c2c6 /test/testtime.c
parent9c48e408eb3256c94b48e7ee180025b4950c5891 (diff)
downloadapr-171fcbd6a5059a3a97f2b3662d9a5a6b935c97d5.tar.gz
More changes to the time test.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@61454 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/testtime.c')
-rw-r--r--test/testtime.c43
1 files changed, 35 insertions, 8 deletions
diff --git a/test/testtime.c b/test/testtime.c
index 1d58508d6..4c6e2cc18 100644
--- a/test/testtime.c
+++ b/test/testtime.c
@@ -70,6 +70,7 @@ int main(void)
apr_pool_t *p;
char *str;
apr_size_t sz;
+ apr_interval_time_t hr_off = 5 * 3600; /* 5 hours in seconds */
fprintf(stdout, "Testing Time functions.\n");
@@ -78,32 +79,32 @@ int main(void)
exit (-1);
}
- fprintf(stdout, "\tapr_time_now..................");
+ fprintf(stdout, "\tapr_time_now..............................");
now = apr_time_now();
fprintf(stdout, "OK\n");
- fprintf(stdout, "\tapr_explode_localtime.........");
+ fprintf(stdout, "\tapr_explode_localtime.....................");
if (apr_explode_localtime(&xt, now) != APR_SUCCESS) {
fprintf(stderr, "Couldn't explode the time\n");
exit(-1);
}
fprintf(stdout, "OK\n");
- fprintf(stdout, "\tapr_explode_gmt...............");
+ fprintf(stdout, "\tapr_explode_gmt...........................");
if (apr_explode_gmt(&xt, now) != APR_SUCCESS) {
fprintf(stderr, "Couldn't explode the time\n");
exit(-1);
}
fprintf(stdout, "OK\n");
- fprintf(stdout, "\tapr_implode_time..............");
+ fprintf(stdout, "\tapr_implode_time..........................");
if (apr_implode_time(&imp, &xt) != APR_SUCCESS) {
fprintf(stderr, "Couldn't implode the time\n");
exit(-1);
}
- if (imp != now) {
+ if (imp != now) {
fprintf(stderr, "implode/explode mismatch\n"
- "apr_explode of apr_now() %15I64d\n"
+ "apr_explode of apr_now() %lld\n"
"apr_implode() returned %15I64d\n"
"error delta was %15I64d\n",
now, imp, imp-now);
@@ -111,7 +112,7 @@ int main(void)
}
fprintf(stdout, "OK\n");
- printf("\tapr_strftime..................");
+ printf("\tapr_strftime....................");
str = (char*) apr_pcalloc(p, sizeof(char) * 30);
if (str == NULL){
printf("Couldn't allocate memory.\n");
@@ -120,9 +121,35 @@ int main(void)
if (apr_strftime(str, &sz, 30, "%R %A %d %B %Y", &xt) !=
APR_SUCCESS){
printf("Failed!");
+ exit (-1);
}
printf("%s\n", str);
-
+
+ printf("\tTime Zone (???)...........................");
+ if (apr_strftime(str, &sz, 30, "%R %Z", &xt) != APR_SUCCESS){
+ printf("Failed!\n");
+ exit (-1);
+ }
+ printf ("%s\n", str);
+
+ xt.tm_gmtoff = hr_off; /* 5 hour offset */
+ printf("\tOffset Time Zone -5 hours.................");
+ if (apr_strftime(str, &sz, 30, "%R %Z", &xt) != APR_SUCCESS){
+ printf("Failed!\n");
+ exit(-1);
+ }
+ printf("%s\n", str);
+
+ printf("\tChecking imploded time after offset.......");
+ apr_implode_time(&imp, &xt);
+ hr_off *= APR_USEC_PER_SEC; /* microseconds */
+ if (imp != now - hr_off){
+ printf("Failed! :(\n");
+ printf("Difference is %lld (should be %lld)\n", imp - now, hr_off);
+ exit(-1);
+ }
+ printf("OK\n");
+
return 1;
}