calendar

BSD calendar reimplementation
git clone https://git.ce9e.org/calendar.git

commit
fc16cba7ce33443153e327e18df7ee8016b8224d
parent
132581f1b3d4d9d84707da59febef424e7984e16
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2018-11-19 07:19
c: fix date parsing

Diffstat

M calendar.c 12 ++++++------

1 files changed, 6 insertions, 6 deletions


diff --git a/calendar.c b/calendar.c

@@ -221,7 +221,7 @@ struct tpl parse_date(char *s) {
  221   221 		tpl.month = match.tm_mon + 1;
  222   222 		tpl.weekday = match.tm_wday + 1;
  223   223 		if (!star) {
  224    -1 			tpl.year = match.tm_mday + 2000;
   -1   224 			tpl.year = match.tm_year + 1900;
  225   225 		}
  226   226 		tpl.nth_of_month = n;
  227   227 		return tpl;
@@ -229,14 +229,14 @@ struct tpl parse_date(char *s) {
  229   229 		tpl.month = match.tm_mon + 1;
  230   230 		tpl.weekday = match.tm_wday + 1;
  231   231 		if (!star) {
  232    -1 			tpl.year = TODAY->tm_mday + 2000;
   -1   232 			tpl.year = TODAY->tm_year + 1900;
  233   233 		}
  234   234 		tpl.nth_of_month = n;
  235   235 		return tpl;
  236   236 	} else if (strptime(s, "%a", &match)) {
  237   237 		tpl.weekday = match.tm_wday + 1;
  238   238 		if (!star) {
  239    -1 			tpl.year = TODAY->tm_mday + 2000;
   -1   239 			tpl.year = TODAY->tm_year + 1900;
  240   240 		}
  241   241 		tpl.nth_of_month = n;
  242   242 		return tpl;
@@ -247,7 +247,7 @@ struct tpl parse_date(char *s) {
  247   247 		tpl.month = match.tm_mon + 1;
  248   248 		tpl.day = match.tm_mday;
  249   249 		if (!star) {
  250    -1 			tpl.year = match.tm_mday + 2000;
   -1   250 			tpl.year = match.tm_year + 1900;
  251   251 		}
  252   252 		tpl.repeat = n;
  253   253 		return tpl;
@@ -255,7 +255,7 @@ struct tpl parse_date(char *s) {
  255   255 		tpl.month = match.tm_mon + 1;
  256   256 		tpl.day = match.tm_mday;
  257   257 		if (!star) {
  258    -1 			tpl.year = TODAY->tm_mday + 2000;
   -1   258 			tpl.year = TODAY->tm_year + 1900;
  259   259 			if (match.tm_mon < TODAY->tm_mon) {
  260   260 				tpl.year += 1;
  261   261 			}
@@ -264,7 +264,7 @@ struct tpl parse_date(char *s) {
  264   264 	} else if (strptime(s, "%d", &match)) {
  265   265 		tpl.day = match.tm_mday;
  266   266 		if (!star) {
  267    -1 			tpl.year = TODAY->tm_mday + 2000;
   -1   267 			tpl.year = TODAY->tm_year + 1900;
  268   268 		}
  269   269 		return tpl;
  270   270 	}