8335b1
diff --git a/support/rotatelogs.c b/support/rotatelogs.c
8335b1
index d75d018..216bb12 100644
8335b1
--- a/support/rotatelogs.c
8335b1
+++ b/support/rotatelogs.c
8335b1
@@ -178,14 +178,14 @@ static void usage(const char *argv0, const char *reason)
8335b1
     exit(1);
8335b1
 }
8335b1
 
8335b1
-/*
8335b1
- * Get the unix time with timezone corrections
8335b1
- * given in the config struct.
8335b1
- */
8335b1
-static int get_now(rotate_config_t *config)
8335b1
+/* This function returns the current Unix time (time_t) plus any
8335b1
+ * configured or derived local time offset.  The offset applied is
8335b1
+ * returned via *offset. */
8335b1
+static int get_now(rotate_config_t *config, apr_int32_t *offset)
8335b1
 {
8335b1
     apr_time_t tNow = apr_time_now();
8335b1
-    int utc_offset = config->utc_offset;
8335b1
+    int utc_offset;
8335b1
+
8335b1
     if (config->use_localtime) {
8335b1
         /* Check for our UTC offset before using it, since it might
8335b1
          * change if there's a switch between standard and daylight
8335b1
@@ -195,6 +195,13 @@ static int get_now(rotate_config_t *config)
8335b1
         apr_time_exp_lt(&lt, tNow);
8335b1
         utc_offset = lt.tm_gmtoff;
8335b1
     }
8335b1
+    else {
8335b1
+        utc_offset = config->utc_offset;
8335b1
+    }
8335b1
+
8335b1
+    if (offset)
8335b1
+        *offset = utc_offset;
8335b1
+
8335b1
     return (int)apr_time_sec(tNow) + utc_offset;
8335b1
 }
8335b1
 
8335b1
@@ -258,13 +265,13 @@ static void checkRotate(rotate_config_t *config, rotate_status_t *status)
8335b1
             status->rotateReason = ROTATE_SIZE;
8335b1
         }
8335b1
         else if (config->tRotation) {
8335b1
-            if (get_now(config) >= status->tLogEnd) {
8335b1
+            if (get_now(config, NULL) >= status->tLogEnd) {
8335b1
                 status->rotateReason = ROTATE_TIME;
8335b1
             }
8335b1
         }
8335b1
     }
8335b1
     else if (config->tRotation) {
8335b1
-        if (get_now(config) >= status->tLogEnd) {
8335b1
+        if (get_now(config, NULL) >= status->tLogEnd) {
8335b1
             status->rotateReason = ROTATE_TIME;
8335b1
         }
8335b1
     }
8335b1
@@ -371,12 +378,16 @@ static void post_rotate(apr_pool_t *pool, struct logfile *newlog,
8335b1
 static void doRotate(rotate_config_t *config, rotate_status_t *status)
8335b1
 {
8335b1
 
8335b1
-    int now = get_now(config);
8335b1
+    apr_int32_t offset;
8335b1
+    int now;
8335b1
     int tLogStart;
8335b1
     apr_status_t rv;
8335b1
     struct logfile newlog;
8335b1
     int thisLogNum = -1;
8335b1
 
8335b1
+    /* Retrieve local-time-adjusted-Unix-time. */
8335b1
+    now = get_now(config, &offset);
8335b1
+
8335b1
     status->rotateReason = ROTATE_NONE;
8335b1
 
8335b1
     if (config->tRotation) {
8335b1
@@ -401,7 +412,13 @@ static void doRotate(rotate_config_t *config, rotate_status_t *status)
8335b1
         apr_time_exp_t e;
8335b1
         apr_size_t rs;
8335b1
 
8335b1
-        apr_time_exp_gmt(&e, tNow);
8335b1
+        /* Explode the local-time-adjusted-Unix-time into a struct tm,
8335b1
+         * first *reversing* local-time-adjustment applied by
8335b1
+         * get_now() if we are using localtime. */
8335b1
+        if (config->use_localtime)
8335b1
+            apr_time_exp_lt(&e, tNow - apr_time_from_sec(offset));
8335b1
+        else
8335b1
+            apr_time_exp_gmt(&e, tNow);
8335b1
         apr_strftime(newlog.name, &rs, sizeof(newlog.name), config->szLogRoot, &e);
8335b1
     }
8335b1
     else {
8335b1
@@ -648,7 +665,7 @@ int main (int argc, const char * const argv[])
8335b1
         nRead = sizeof(buf);
8335b1
 #if APR_FILES_AS_SOCKETS
8335b1
         if (config.create_empty && config.tRotation) {
8335b1
-            polltimeout = status.tLogEnd ? status.tLogEnd - get_now(&config) : config.tRotation;
8335b1
+            polltimeout = status.tLogEnd ? status.tLogEnd - get_now(&config, NULL) : config.tRotation;
8335b1
             if (polltimeout <= 0) {
8335b1
                 pollret = APR_TIMEUP;
8335b1
             }