unsigned int MJD2YMD(unsigned long MJD, unsigned int *Y , unsigned int *M, unsigned int *D)
{
unsigned int year, month, day;
unsigned short K;
unsigned short dayInMonth[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
year = ( (MJD) * 100 - 1507820 ) / 36525;
month = ( (MJD) * 10000 - 149561000 - year * 36525 / 100 * 10000 ) / 306001;
day = (MJD) - 14956 - (year * 36525) / 100 - (month * 306001) / 10000;
if ( month == 14 || month == 15 )
{
K = 1;
}
else
{
K = 0;
}
year = year + K ;
month = month - 1 - K * 12;
// day = day;
//瑞年判断
if (( year % 4 == 0) && ( year % 400 != 0))
{
dayInMonth[2] = 29;
}
if ( day > dayInMonth[ month])
{
day -= dayInMonth[ month];
month += 1;
if ( month > 12)
{
month -= 12;
year += 1;
}
}
*Y = year + 1900;
*M = month;
*D = day;
return 1;
}
MJD时间转换成年月日
最新推荐文章于 2023-12-13 19:48:42 发布