aboutsummaryrefslogtreecommitdiffstats
path: root/src/calendar.c
diff options
context:
space:
mode:
authorkatherine <ageha@airen-no-jikken.icu>2020-01-07 14:51:09 -0700
committerkatherine <ageha@airen-no-jikken.icu>2020-01-07 14:51:09 -0700
commit1ccfd37f5513ed29a61325a81944386da4e2a737 (patch)
treeb294bc89bf3190725184929ca1fcddca5ab5c4db /src/calendar.c
parent3cfd9c38e563dec8202e9af84a8e5c9e7f503db1 (diff)
downloadevery-1ccfd37f5513ed29a61325a81944386da4e2a737.tar.gz
more efficient entry checking
it's a mess, but should work
Diffstat (limited to 'src/calendar.c')
-rw-r--r--src/calendar.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/calendar.c b/src/calendar.c
index bcf06f6..b852b1c 100644
--- a/src/calendar.c
+++ b/src/calendar.c
@@ -146,7 +146,7 @@ static struct entry_interval_s sub_get_interval(struct state_s *s)
return iv;
}
- if (l > INT_MAX) {
+ if (l > INT_MAX - 365) {
ERRP("time interval too large");
s->err_flag = true;
return iv;
@@ -229,7 +229,7 @@ static time_t sub_get_date(struct state_s *s)
int i;
char c;
time_t rt = 0;
- struct tm tmp;
+ struct tm ttmp;
struct tm t = {
.tm_year = 2000,
.tm_mday = 1,
@@ -346,7 +346,7 @@ skip_num:
}
validate:
- tmp = t;
+ ttmp = t;
/* NOTE: timegm is non-POSIX, but commonplace */
if (s->cur_local)
@@ -359,13 +359,18 @@ validate:
s->err_flag = true;
}
+ if (s->cur_local)
+ t = *localtime(&rt);
+ else
+ t = *gmtime(&rt);
+
if (
- tmp.tm_year != t.tm_year ||
- tmp.tm_mon != t.tm_mon ||
- tmp.tm_mday != t.tm_mday ||
- tmp.tm_hour != t.tm_hour ||
- tmp.tm_min != t.tm_min ||
- tmp.tm_sec != t.tm_sec
+ ttmp.tm_year != t.tm_year ||
+ ttmp.tm_mon != t.tm_mon ||
+ ttmp.tm_mday != t.tm_mday ||
+ ttmp.tm_hour != t.tm_hour ||
+ ttmp.tm_min != t.tm_min ||
+ ttmp.tm_sec != t.tm_sec
) {
ERRP("invalid date");
s->err_flag = true;