return value;
}
+int _few_arguments(const char* argv[])
+{
+ printf("ERROR: %s <begin_hours> <begin_minutes>\n", argv[0]);
+ return EXIT_FAILURE;
+}
+
+int _invalid_arguments()
+{
+ printf("ERROR: one or more invalid arguments\n");
+ return EXIT_FAILURE;
+}
+
int main(const int argc, const char* argv[])
{
- if (argc < 3) {
- printf("ERROR: %s <begin_hours> <begin_minutes>\n", argv[0]);
- return 1;
- }
+ if (argc < 3)
+ return _few_arguments(argv);
- if (!validate_hourstring(argv[1]) || !validate_minutestring(argv[2])) {
- printf("ERROR: one or more invalid arguments\n");
- return 1;
- }
+ const char* hour = argv[1];
+ const char* min = argv[2];
+ if (!validate_hourstring(hour) || !validate_minutestring(min))
+ return _invalid_arguments();
printf("Version: %s\n\n", PROJECT_VERSION);
const struct tm now_tm = _init_tm_with_time(NULL, NULL);
const time_t now = mktime((struct tm*) &now_tm);
- const struct tm begin_tm = _init_tm_with_time(argv[1], argv[2]);
+ const struct tm begin_tm = _init_tm_with_time(hour, min);
const time_t begin = mktime((struct tm*) &begin_tm);
const time_t worktime_eight_end = get_eight_hour_end_worktime(begin);
const struct tm work_eight_end_tm = _get_tm_from_time(worktime_eight_end);
_print_time_to_end_worktime(diff_to_end);
_print_time_to_max_end_worktime(diff_to_max_end);
- return 0;
+ return EXIT_SUCCESS;
}
\ No newline at end of file