#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void Julian2UTC(int week,int seconds,int *year,int *month,int *day)
{
int JD = 2444245;
double L,N,I,J;
week = week * 7 + floor(seconds/86400);
L = JD + 68569 + week;
N = floor(( 4 * L ) / 146097);
L = L - floor(( 146097 *N + 3 ) / 4);
I = floor(( 4000 * ( L + 1 ) ) / 1461001);
L = L - floor(( 1461 * I ) / 4) + 31;
J = floor(( 80 * L ) / 2447);
*day = L - floor(( 2447 * J ) / 80);
L = floor(J / 11);
*month = J + 2 - ( 12 *L );
*year = 100 * ( N - 49 ) + I + L;
}
void main()
{
int week,seconds;
int year,month,day;
scanf("%d,%d",&week,&seconds);
Julian2UTC(week,seconds,&year,&month,&day);
printf("year = %d\nmonth = %d\nday = %d\n",year,month,day);
system("pause");
}
评论1