[Gpredict-svn] SF.net SVN: gpredict:[415] trunk/src/gtk-sat-module-tmg.c
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
From: <cs...@us...> - 2009-08-14 10:22:07
|
Revision: 415 http://gpredict.svn.sourceforge.net/gpredict/?rev=415&view=rev Author: csete Date: 2009-08-14 10:21:55 +0000 (Fri, 14 Aug 2009) Log Message: ----------- Implemented wrap around for the days as well. Modified Paths: -------------- trunk/src/gtk-sat-module-tmg.c Modified: trunk/src/gtk-sat-module-tmg.c =================================================================== --- trunk/src/gtk-sat-module-tmg.c 2009-08-12 17:04:03 UTC (rev 414) +++ trunk/src/gtk-sat-module-tmg.c 2009-08-14 10:21:55 UTC (rev 415) @@ -746,22 +746,109 @@ static void tmg_cal_add_one_day (GtkSatModule *mod) { guint year, month, day; + gint hr, min, sec, msec; + struct tm tim,utim; + gdouble jd; + + /* calculate the new time as in tmg_time_set */ gtk_calendar_get_date (GTK_CALENDAR (mod->tmgCal), &year, &month, &day); + hr = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (mod->tmgHour)); + min = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (mod->tmgMin)); + sec = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (mod->tmgSec)); + msec = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (mod->tmgMsec)); - /* calculate the new time as in tmg_time_set then call tmg_update_widgets */ + /* build struct_tm */ + tim.tm_year = (int) (year); + tim.tm_mon = (int) (month+1); + tim.tm_mday = (int) day; + tim.tm_hour = (int) hr; + tim.tm_min = (int) min; + tim.tm_sec = (int) sec; + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: %d/%d/%d %d:%d:%d.%d"), + __FUNCTION__, + tim.tm_year, tim.tm_mon, tim.tm_mday, + tim.tm_hour, tim.tm_min, tim.tm_sec, msec); + + /* convert UTC time to Julian Date */ + if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) { + /* convert local time to UTC */ + utim = Time_to_UTC (&tim); + + /* Convert to JD */ + jd = Julian_Date (&utim); + } + else { + /* Already UTC, just convert to JD */ + jd = Julian_Date (&tim); + } + + jd = jd + (gdouble)msec/8.64e+7; + + /* add one day */ + jd += 1; + + mod->tmgCdnum = jd; + + /* now call tmg_update_widgets */ + tmg_update_widgets (mod); } + /** \brief Substract one day from the calendar */ static void tmg_cal_sub_one_day (GtkSatModule *mod) { guint year, month, day; + gint hr, min, sec, msec; + struct tm tim,utim; + gdouble jd; + + /* calculate the new time as in tmg_time_set */ gtk_calendar_get_date (GTK_CALENDAR (mod->tmgCal), &year, &month, &day); + hr = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (mod->tmgHour)); + min = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (mod->tmgMin)); + sec = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (mod->tmgSec)); + msec = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (mod->tmgMsec)); - /* calculate the new time as in tmg_time_set then call tmg_update_widgets */ + /* build struct_tm */ + tim.tm_year = (int) (year); + tim.tm_mon = (int) (month+1); + tim.tm_mday = (int) day; + tim.tm_hour = (int) hr; + tim.tm_min = (int) min; + tim.tm_sec = (int) sec; + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: %d/%d/%d %d:%d:%d.%d"), + __FUNCTION__, + tim.tm_year, tim.tm_mon, tim.tm_mday, + tim.tm_hour, tim.tm_min, tim.tm_sec, msec); + + /* convert UTC time to Julian Date */ + if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) { + /* convert local time to UTC */ + utim = Time_to_UTC (&tim); + + /* Convert to JD */ + jd = Julian_Date (&utim); + } + else { + /* Already UTC, just convert to JD */ + jd = Julian_Date (&tim); + } + + jd = jd + (gdouble)msec/8.64e+7; + + /* substract one day */ + jd -= 1; + + mod->tmgCdnum = jd; + + /* now call tmg_update_widgets */ + tmg_update_widgets (mod); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |