Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <string.h>
- #include <stdint.h>
- enum
- {
- BEG_YEAR = 1925,
- BEG_MON = 10,
- BEG_DAY = 7
- };
- int
- main()
- {
- struct tm beg_date = {0};
- beg_date.tm_isdst = -1;
- beg_date.tm_year = BEG_YEAR - 1900;
- beg_date.tm_mon = BEG_MON - 1;
- beg_date.tm_mday = BEG_DAY;
- long long beg_date_comp = mktime(&beg_date);
- struct tm now_date = {0};
- now_date.tm_isdst = -1;
- while(scanf("%d %d %d", &now_date.tm_year, &now_date.tm_mon, &now_date.tm_mday) == 3) {
- now_date.tm_year -= 1900;
- now_date.tm_mon -= 1;
- now_date.tm_hour = 12;
- long long now_date_comp = mktime(&now_date);
- if (now_date_comp == -1) {
- return -1;
- }
- long long hark_date_comp = now_date_comp - beg_date_comp;
- int hark_date_comp_indays = hark_date_comp / 60 / 60 / 24;
- int hark_date_year = 1 + hark_date_comp_indays / 12 / 30;
- int hark_date_mon = 1 + hark_date_comp_indays / 30 % 12;
- int hark_date_mday = 1 + hark_date_comp_indays % 30;
- printf("%d ", hark_date_year);
- printf("%d ", hark_date_mon);
- printf("%d\n", hark_date_mday);
- memset(&now_date, 0, sizeof(now_date));
- now_date.tm_isdst = -1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement