Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main(){
- int months[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
- 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
- 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
- 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
- int time = 1330492354;
- int days = time / (60*60*24);
- time %= (60*60*24);
- int hours = time / (60*60);
- time %= (60*60);
- int minutes = time / (60);
- time %= (60);
- int seconds = time;
- int years = 1970;
- int i, d2 = days;
- for( i = 0; d2 > months[i%48]; ++i ){
- d2 -= months[i%48];
- }
- years += i / 12;
- int month = i % 12;
- char* monthstr[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
- printf(" The date provided is %s %i, %i, and the time is %i:%i.%i\n", monthstr[month], d2+1, years, hours, minutes, seconds );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement