diff options
-rw-r--r-- | src/main-cynadm.c | 13 | ||||
-rw-r--r-- | src/main-cynarad.c | 8 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/main-cynadm.c b/src/main-cynadm.c index e5318a1..fa44895 100644 --- a/src/main-cynadm.c +++ b/src/main-cynadm.c @@ -33,9 +33,10 @@ char *str[40]; int nstr; static const int MIN = 60; -static const int HOUR = 60*MIN; -static const int DAY = 24*HOUR; -static const int YEAR = 365*DAY; +static const int HOUR = 60*60; +static const int DAY = 24*60*60; +static const int WEEK = 7*24*60*60; +static const int YEAR = 365*24*60*60; const char *client, *session, *user, *permission, *value; time_t expire; @@ -56,6 +57,7 @@ time_t txt2exp(const char *txt) x = 10 * x + (time_t)(*txt++ - '0'); switch(*txt) { case 'y': r += x * YEAR; txt++; break; + case 'w': r += x * WEEK; txt++; break; case 'd': r += x *= DAY; txt++; break; case 'h': r += x *= HOUR; txt++; break; case 'm': r += x *= MIN; txt++; break; @@ -81,6 +83,11 @@ const char *exp2txt(time_t expire) (long long)(expire / YEAR)); expire = expire % YEAR; } + if (expire >= WEEK) { + n += snprintf(&buffer[n], sizeof buffer - n, "%lldw", + (long long)(expire / WEEK)); + expire = expire % WEEK; + } if (expire >= DAY) { n += snprintf(&buffer[n], sizeof buffer - n, "%lldd", (long long)(expire / DAY)); diff --git a/src/main-cynarad.c b/src/main-cynarad.c index 5744672..1829d74 100644 --- a/src/main-cynarad.c +++ b/src/main-cynarad.c @@ -439,9 +439,10 @@ static void ensure_directory(const char *path, int uid, int gid) time_t txt2exp(const char *txt) { static const int MIN = 60; - static const int HOUR = 60*MIN; - static const int DAY = 24*HOUR; - static const int YEAR = 365*DAY; + static const int HOUR = 60*60; + static const int DAY = 24*60*60; + static const int WEEK = 7*24*60*60; + static const int YEAR = 365*24*60*60; time_t r, x; @@ -454,6 +455,7 @@ time_t txt2exp(const char *txt) x = 10 * x + (time_t)(*txt++ - '0'); switch(*txt) { case 'y': r += x * YEAR; txt++; break; + case 'w': r += x *= WEEK; txt++; break; case 'd': r += x *= DAY; txt++; break; case 'h': r += x *= HOUR; txt++; break; case 'm': r += x *= MIN; txt++; break; |