Author: viethen Date: Thu Mar 22 17:35:16 2012 New Revision: 2949 Log: Added copyright header, changed sizeof()s, removed one redundant pair of parentheses, plus a few cosmetic changes, as per Diego's recommendations. Modified: trunk/pairing/util/pisa-pairing-date.c Modified: trunk/pairing/util/pisa-pairing-date.c ============================================================================== --- trunk/pairing/util/pisa-pairing-date.c Thu Mar 22 17:05:40 2012 (r2948) +++ trunk/pairing/util/pisa-pairing-date.c Thu Mar 22 17:35:16 2012 (r2949) @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2012, Distributed Systems Group, RWTH Aachen + * All rights reserved. + */ + /** * @file * This program will verify a date string of the format yyyy-mm-dd for @@ -21,6 +26,7 @@ * @brief verify and increment date strings in yyyy-mm-dd format. * @author Christoph Viethen <christoph.viethen@xxxxxxxxxxxxxx> */ + #include <inttypes.h> #include <stdbool.h> #include <stdio.h> @@ -40,7 +46,7 @@ int year, month; struct tm first_of_following_month; struct tm last_of_target_month; - time_t timestamp = 0; + time_t timestamp = 0; if (input_date_string == NULL || offset_string == NULL) { return; @@ -59,7 +65,7 @@ /* add the offset plus one more month, yielding the month following * the actual target ... */ - month += (offset + 1); + month += offset + 1; if (month > 12) { year += (month - 1) / 12; @@ -67,7 +73,8 @@ } /* ... and express the first day of that following month */ - memset(&first_of_following_month, 0, sizeof(struct tm)); + memset(&first_of_following_month, 0, sizeof(first_of_following_month)); + first_of_following_month.tm_year = year - 1900; first_of_following_month.tm_mon = month - 1; first_of_following_month.tm_mday = 1; @@ -88,7 +95,8 @@ return; } - printf("%04d-%02d-%02d\n", last_of_target_month.tm_year + 1900, last_of_target_month.tm_mon + 1, last_of_target_month.tm_mday); + printf("%04d-%02d-%02d\n", last_of_target_month.tm_year + 1900, + last_of_target_month.tm_mon + 1, last_of_target_month.tm_mday); } static bool verify_offset(const char *offset_string) @@ -137,7 +145,7 @@ return false; } - memset(&input_date, 0, sizeof(struct tm)); + memset(&input_date, 0, sizeof(input_date)); input_date.tm_year = year - 1900; input_date.tm_mon = month - 1; input_date.tm_mday = day; -- This is the pisa developer mailing list. Please also subscribe to the main pisa list at: //www.freelists.org/list/pisa