// a.c // // Copyright 2011 German Gutierrez // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, // MA 02110-1301, USA. #include #include #include int julianDayGuess(int, int); int main(void) { int dd; int mm; time_t ahora; struct tm *ptr_ts; time(&ahora); ptr_ts = gmtime ( &ahora ); dd = ptr_ts->tm_mday; /*recuperamos el dia del mes*/ mm = ptr_ts->tm_mon; /* van de 0 a 11 */ mm +=1; /* agregamos el offset*/ printf("%d ", julianDayGuess(mm,dd)); return EXIT_SUCCESS; } int julianDayGuess(mm, dd) { int result; /*Si mm == 2 (febrero), incrementar el valor de día en 1.*/ dd+=(mm==2)? 1:0; result = (int) (30.42*(mm-1))+dd; return result; }