Skip to content

Instantly share code, notes, and snippets.

@surgicalmaskman
Created September 1, 2013 17:38
Show Gist options
  • Save surgicalmaskman/6406014 to your computer and use it in GitHub Desktop.
Save surgicalmaskman/6406014 to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include<time.h>
int main(int argc , char *argv[])
{
time_t now;
int year;
int month;
int day;
int foo;
struct tm *t_st;
time(&now);
t_st = localtime(&now);
year = t_st->tm_year+1900;
month = t_st->tm_mon+1;
day = t_st->tm_mday;
if(month == 1 || month == 2){
year--;
month+=12;
}
foo = (365.25 * year) + ( year / 400) - (year /100) + (30.59 * (month - 2)) + day - 678912;
printf("%d\n",foo);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment