@@ -318,12 +318,10 @@ static void *r_file_pread(request_rec *r, char *fname,
318
318
else {
319
319
// check to see if there is a period
320
320
if (sizeof (time_period ) > 0 ) {
321
- apr_time_exp_t st = {0 };
322
- apr_time_exp_t end = {0 };
321
+ apr_time_exp_t st ; st .tm_year = 0 ;st .tm_mon = 0 ;st .tm_mday = 1 ;st .tm_yday = 1 ;st .tm_hour = 0 ;st .tm_min = 0 ;st .tm_sec = 0 ;
323
322
int interval = 0 ;
324
323
int start_offset = 0 ;
325
324
int start_leap = 0 ;
326
- int end_leap = 0 ;
327
325
int i ;
328
326
for (i = 0 ;i < num_periods ;i ++ ) {
329
327
ap_log_error (APLOG_MARK ,APLOG_WARNING ,0 ,r -> server ,"Evaluating time period %s" , time_period );
@@ -365,7 +363,7 @@ static void *r_file_pread(request_rec *r, char *fname,
365
363
// get the offset from starting date
366
364
start_offset = tm .tm_yday - st .tm_yday ;
367
365
// add prior years if not monthly
368
- if (time_period [(strlen (time_period )- 1 )] != 'M' ) {
366
+ if (time_period [(strlen (time_period )- 1 )] != 'M' && hastime == 0 ) {
369
367
while (tm .tm_year > st .tm_year ) {
370
368
if ((st .tm_year %4 )?0 :((st .tm_year %400 )?((st .tm_year %100 )?1 :0 ):1 )== 1 ) {
371
369
start_offset += 366 ;
@@ -376,24 +374,15 @@ static void *r_file_pread(request_rec *r, char *fname,
376
374
}
377
375
}
378
376
379
- time_period += 2 ; // Advance to date or time separator
380
- if (* time_period == 'T' ) { // if hhmmss are included in time period
377
+ // if hhmmss are included in time period
378
+ if (strlen ( time_period ) > 11 ) {
381
379
time_period += 3 ;
382
380
st .tm_hour = apr_atoi64 (time_period );
383
381
time_period += 3 ;
384
382
st .tm_min = apr_atoi64 (time_period );
385
383
time_period += 3 ;
386
384
st .tm_sec = apr_atoi64 (time_period );
387
385
}
388
- time_period += 1 ; // Advance to period end date
389
-
390
- end .tm_year = apr_atoi64 (time_period );
391
- time_period += 5 ;
392
- end .tm_mon = apr_atoi64 (time_period );
393
- time_period += 3 ;
394
- end .tm_mday = apr_atoi64 (time_period );
395
- end_leap = (end .tm_year %4 )?0 :((end .tm_year %400 )?((end .tm_year %100 )?1 :0 ):1 );
396
- end .tm_yday = end .tm_mday + moffset [end .tm_mon - 1 ]+ ((end .tm_mon > 2 )?end_leap :0 );
397
386
398
387
// ap_log_error(APLOG_MARK,APLOG_WARNING,0,r->server,"DEBUG Start time period: year %d month %d day %d hour %d minute %d second %d offset %d interval %d", st.tm_year, st.tm_mon, st.tm_mday, st.tm_hour, st.tm_min, st.tm_sec, start_offset, interval);
399
388
@@ -410,12 +399,9 @@ static void *r_file_pread(request_rec *r, char *fname,
410
399
span = request_day ; // store old value
411
400
request_day = tm .tm_mday + moffset [tm .tm_mon - interval ]+ ((tm .tm_mon > 2 )?leap :0 );
412
401
span = span - request_day + 1 ; // get actual span
413
- } else if ( request_day <= end . tm_yday ) {
402
+ } else {
414
403
// ap_log_error(APLOG_MARK,APLOG_WARNING,0,r->server,"%d [request day] - (%d [days since start] %% %d [period interval]) = %d [date]", request_day, start_offset, interval, (request_day-span));
415
404
request_day = request_day - span ;
416
- } else {
417
- time_period += strlen (time_period )+ 1 ;
418
- continue ;
419
405
}
420
406
}
421
407
char old_char = * (fnloc + 7 );
@@ -426,21 +412,21 @@ static void *r_file_pread(request_rec *r, char *fname,
426
412
int request_secs = (tm .tm_hour * 3600 ) + (tm .tm_min * 60 ) + tm .tm_sec ;
427
413
start_offset = ((tm .tm_yday * 86400 ) + request_secs ) - ((start_offset * 86400 ) + (st .tm_hour * 3600 ) + (st .tm_min * 60 ) + st .tm_sec );
428
414
429
- // calculate the last date in the span of the time interval
415
+ // calculate the last time in the span of the time interval
430
416
int span = start_offset % interval ;
431
417
// ap_log_error(APLOG_MARK,APLOG_WARNING,0,r->server,"%d [request seconds] - (%d [seconds since start] %% %d [period in seconds]) = %d [granule time in seconds]", request_secs, start_offset, interval, (request_secs-span));
432
418
request_secs = request_secs - span ;
433
419
434
420
// convert seconds to hhmmss
435
- tm . tm_hour = request_secs /3600 ;
421
+ int tm_hour = request_secs /3600 ;
436
422
request_secs = request_secs %3600 ;
437
- tm . tm_min = request_secs /60 ;
423
+ int tm_min = request_secs /60 ;
438
424
request_secs = request_secs %60 ;
439
- tm . tm_sec = request_secs ;
425
+ int tm_sec = request_secs ;
440
426
441
427
char old_char = * (fnloc + 13 );
442
- // ap_log_error(APLOG_MARK,APLOG_WARNING,0,r->server,"period time is %04d-%02d-%02dT%02d:%02d:%02d", tm.tm_year, tm.tm_mon, tm.tm_mday, tm. tm_hour, tm. tm_min, tm. tm_sec);
443
- sprintf (fnloc ,"%04d%03d%02d%02d%02d" ,tm .tm_year ,tm .tm_yday , tm . tm_hour , tm . tm_min , tm . tm_sec );
428
+ // ap_log_error(APLOG_MARK,APLOG_WARNING,0,r->server,"period time is %04d-%02d-%02dT%02d:%02d:%02d", tm.tm_year, tm.tm_mon, tm.tm_mday, tm_hour, tm_min, tm_sec);
429
+ sprintf (fnloc ,"%04d%03d%02d%02d%02d" ,tm .tm_year ,tm .tm_yday , tm_hour , tm_min , tm_sec );
444
430
* (fnloc + 13 )= old_char ;
445
431
}
446
432
0 commit comments