Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <time.h>
- enum
- {
- GREG_YEAR = 1925,
- GREG_MON = 10,
- GREG_DAY = 7,
- START_YEAR = 1900,
- SEC_DAY = 24 * 60 * 60,
- SEC_MON = SEC_DAY * 30,
- SEC_YEAR = SEC_MON * 12
- };
- time_t sec(int year, int mon, int day) {
- struct tm ret;
- ret.tm_year = year - START_YEAR;
- ret.tm_mon = mon - 1;
- ret.tm_mday = day;
- ret.tm_isdst = 0;
- ret.tm_hour = 0;
- ret.tm_min = 0;
- ret.tm_sec = 0;
- return mktime(&ret);
- }
- int main() {
- time_t t = time(NULL);
- struct tm lt = {0};
- localtime_r(&t, <);
- int curr_year, curr_mon, curr_day;
- time_t start = sec(GREG_YEAR, GREG_MON, GREG_DAY);
- while (scanf("%d%d%d", &curr_year, &curr_mon, &curr_day) == 3) {
- time_t curr_time = sec(curr_year, curr_mon, curr_day);
- long long sub = (long long) curr_time - (long long) start + lt.tm_gmtoff;
- long long new_year, new_mon, new_day;
- new_year = sub / SEC_YEAR + 1;
- sub %= SEC_YEAR;
- new_mon = sub / SEC_MON + 1;
- sub %= SEC_MON;
- new_day = sub / SEC_DAY + 1;
- printf("%lld %lld %lld\n", new_year, new_mon, new_day);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement