diff options
Diffstat (limited to 'src/conversions/unitconvert.cpp')
| -rw-r--r-- | src/conversions/unitconvert.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/conversions/unitconvert.cpp b/src/conversions/unitconvert.cpp index d584d93f..5a5042f0 100644 --- a/src/conversions/unitconvert.cpp +++ b/src/conversions/unitconvert.cpp @@ -252,21 +252,22 @@ static double yyyymmdd_to_mjd(double yyyymmdd) { /***********************************************************************/ static double mjd_to_yyyymmdd(double mjd) { /************************************************************************ - Date given in YYYY-MM-DD format. + Date returned in YYYY-MM-DD format. ************************************************************************/ - double mjd_iter = 14 + 31; - int year = 1859, month=0, day=0; + unsigned int mjd_iter = 14 + 31; + unsigned int year = 1859, month = 0, day = 0; + unsigned int date = (int) lround(mjd); - for (; mjd >= mjd_iter; year++) { + for (; date >= mjd_iter; year++) { mjd_iter += days_in_year(year); } year--; mjd_iter -= days_in_year(year); - for (month=1; mjd_iter + days_in_month(year, month) <= mjd; month++) + for (month=1; mjd_iter + days_in_month(year, month) <= date; month++) mjd_iter += days_in_month(year, month); - day = (int)(mjd - mjd_iter + 1); + day = date - mjd_iter + 1; return year*10000.0 + month*100.0 + day; } |
